Okay so I am using fishnets OnStartClient and OnStopClient methods. When I start the client I find a GameObject and when I stop it i'm trying to access the gameObject that was found onStart.
So I tested it out. When I stop and start the client 3 times, it works on the third time (Everytime). The first two tries:
To me it makes absolutely no sense why it works on the third run but not the first two. Does anyone have any input on this?
public override void OnStopClient()
{
base.OnStopClient();
// This is what i'm getting nullReferenceException on but only sometimes.
// I find thee invPanel in the onclient start using
// invPanel = GameObject.FindGameObjectWithTag("InventoryPanel");
if (!invPanel.activeSelf)
{
invPanel.SetActive(true);
}
}
I have tried everything I can think of along with researching the issue, but wasn't too successful on finding anything relating to my issue.
I was expecting it to either always find the object or always produce null reference exception. Makes no sense for it to work exactly on the third try everytime but not the first two tries.
So still not sure what the issue was but I believe I fixed it but just using OnApplicationQuit instead of OnStopClient.