- Home /
script execution order for instatiated prefabs
It looks like the script execution order is not followed when a prefab is instantiated in run-time. Do you agree?
Answer by nschrag · Apr 05, 2012 at 08:33 PM
I have seen this behaviour, but haven't been able to reproduce it 100% of the time. Are you seeing this when calling GameObject.Instantiate from a coroutine?
well not directly, but it is true that I was waiting for a series of coroutine to finish and only at the end the prefab was instantiated. It is possible that the instantiation was actually triggered by a coroutine.
Answer by xadhoom · Sep 11, 2012 at 02:42 PM
We face the exact same problem at the moment.
When we start the scene containing the prefab the execution order is correct. If we instantiate the same prefab at runtime the order is different. It does not matter if we have OnEnable/Awake/Update etc. in the classes. We tried several implementations and none of them worked correctly when instatiating at runtime. All scripts were directly derived from Monobehaviour...
xad
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Enemy prefab's script won't keep inspector-applied settings. 0 Answers
Static target in the srcipt for my Prefab 2 Answers
unity freezes when prefab is loaded into game 2 Answers
Can someone help me fix my Javascript for Flickering Light? 6 Answers