Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

Standalone server -batchmode isn't using GameObject.Find() to get reference to gameobject

$
0
0
Hi, I have setup a standalone build of my game that will automatically switch to running as a server when ran with the -batchmode option. This seems to work fine for me when I am testing it in the Unity Editor, however when I run the standalone player I keep coming up with null references to the gameobject I am trying to find. Here is the code that I use to try to find the gameObject: bool EnsureDataPersisterLoaded() { if(dataPersister != null) return true; GameObject dataPersisterObj = GameObject.Find("DataPersister"); if (dataPersisterObj != null) { dataPersister = dataPersisterObj.GetComponent(); if (dataPersister != null) return true; } else { Debug.Log("Could not find DataPersister gameObject - ConsoleSystem:EnsurePersisterLoaded()"); } /* dataPersister = Server_DataPersistence.singleton; if (dataPersister != null) return true; */ Debug.LogWarning("Unable to load DataPersister. Some commands may not function properly."); return false; } The "DataPersister" gameObject is instantiated in a 'landing' scene that I have created and have DontDestroyOnLoad(gameObject) set in it's awake method. The odd thing is that this appears to work perfectly fine in the Editor, however does not work in the standalone build. Any insight into what I might be missing would be greatly appreciated. Thank you.

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>