![]() |
BomberUnits
...a Unity learning project
|
Unity provides a two-step approach to the startup phase of a script:
During startup, the Awake() Callback is called once the script is activated. This is done before any Start() Callbacks are called on them. During awake, no assumptions can be made on the state of other behaviours, whose objects are created in the same frame. (Objects of which you know have been created way before will of course be in a stable state.)
The Awake()should thus be used to initialize things internal to the script. As you have no control over the instantiation. Awake() will also be called when the GameObject the script is attached to becomes active. Do things such as:
The Start() Callbacks are called after all awakes are done. Use this to, for example, collect references to other scripts.