Hi,
After upgrading to 5.6 we noticed a change in how our scripts initialize.
previously if we did this:
GameObject myObject = GameObject.Instantiate(m_SpawnObjects[objToSpawn], nodes[i].transform.position, nodes[i].transform.rotation);
myObject.SetActive(false);
Awake() and Start() would run.
Now in 5.6 Start() is no longer running unless we wait a frame. Is this intended behavior?
Yeah this is easy to test.
If you create a gameobject and disable it start is never called. Looks like GameObject.SetActive(false) now happens before Start() under the hood.
intrestingly
Debug.Log(“Awake” + Time.time);
And
Debug.Log(“Start” + Time.time);
Both return 0 so we have an order of operations issue.
What version did you update from.
Because I’m on Unity 5.5 and that’s the behaviour.
And as far as I can recall (my memory may be mistaken), that’s been the behaviour for as long as I’ve been using Unity.
lordofduct:
What version did you update from.
Because I’m on Unity 5.5 and that’s the behaviour.
And as far as I can recall (my memory may be mistaken), that’s been the behaviour for as long as I’ve been using Unity.
Really?
We went from 5.5 to 5.6 and our pooled objects stopped calling start(). Could be that the behavior isn’t directly related and a race condition is created somewhere else.
That said,
I’m fine with the behavior if it’s 100% consistent. E.g. if start() is never called when an object is instantly set to inactive.