Origin: In a hurry to find unity work, the Examiner asked me generally write initialization value, you write in that method inside!
My heart always appeared awake and start, so I want to say awake method. But I can't read .... I asked him if he could write it.
He still agreed to my request, I was happy to write to him on the paper. After a round of discussion he told me to go home and wait for notice.
Premise: do not talk about the awake method can mediate his execution time!
Gameobject is a tree structure, from top to bottom, from the root of the component awake method to execute down, and then the same way to execute the Start method. Not a Awake,start method that executes a awake,start executing another component
Conclusion:
1.1 Gameobject do not need other Gameobject above the component properties to initialize, you choose Awake or Start is not a problem.
(Preferred awake, write this code component in awake (). Enable = false; Start can be paused.)
2. The components on the two gameobject (A, B) A is the parent node of B, A is a component, and a requires a property of reference B to initialize
A is initialized in awake, B is initialized in awake. Error
A at start initialization, B is initialized at start. Error
A at start initialization, B is initialized in awake. Success
3. Components to their own property initialization, must be in awake (), need to call other components to initialize or complete a behavior, should be written in the start ()
Several property initialization options:
attribute = new class name (); Often dry
The construction method has never seen it do this.
Awake () method often dry
Start () method often dry
Choose the initialization difference between awake and start