I have been having a lot of problems with a singular script that contains only a NetworkVariable/NetworkList when a session is created or migrating scenes, as it’s always initially null and exists after every other Start/Awake occurs.
I have the following setup:
- Gameobject that has a single script that only contains a NetworkVariable/NetworkList…
- NetworkManager that has a script which executed to enables the GameObject after a user used the Create Session Widget and had the Joined Session event occur.
When the event from the Create Session Widget Occurs, I essentially get the following:
- Joined Session XXX
- NullReferenceException
Despite the [SerialIzefield] Gameobject being set and showing fine in the editor.
Things Tried -
- Adding a retry makes it find it after 1 failed check.
- Making it a public has no effect on this
- Having it active initially also has no effect(Still shows as null).
- Currently, it’s a don’t destroy object if that has any effect.
- Enabling every other object that references after the fact has them find it fine.
Any ideas or different approach for this? The intent for it is that on a server start a bunch of gameobjects report names for a list etc… to it so it’s available for all clients.