I recently experienced issues Destroying objects whereby the reference to the old object was valid in script even though the object was destroyed and the reference replaced with a new object. I’ve now just experienced a null error from this code:
primary.SetActive(false);
primary=null;
Primary is null in the SetActive call even though I don’t set it to null until after.
So is there a guide/reference anywhere to which Unity actions can happen out of sequence or are otherwise buffered to execute at the end of frame? There seems no mention on the scripting reference. That is, Unity - Scripting API: GameObject.SetActive doesn’t say that the SetActive won’t happen until the next update, leading me to expect it to be immediate, in which case the code shouldn’t execute out of order as it is.