UNITY TUTORIAL | SCRIPTING | Awake() and Start()
Awake()
- Awake() is called first even if the script component is not enabled
- Awake() is best used for setting up any references between scripts and initialization
Start()
- Start() is called after Awake() immediately before the first Update()
- Start() is called only if the script component is enabled
- Start() is used for anything we need to occur
- Start() is only called once in the life time of a script on a gameObject
- It is impossible to repeat Start()
- all of the codes in Start() are called on the first frame that the script is active
Example)
- Awake()
- set ammo for “enemy” gameObject
- Start()
- allow “enemy” to shot


