Unity Awake vs Start Event - Differences and Similarity


Unity MonoBehaviour offers different magic events that you can attach to any GameObject. In this unity tutorial I will explain awake or start events as they both mostly use for assignment purposes.

Awake:  Awake is invoked when the MonoBehaviour is created. You may view it as your default constructor
Start: Start event executes after all initialization is done and the first frame for the behavior is about to run. Start runs right before the Update event.
Similarity:
Start/Awake are called exactly once in the lifetime of the script.
Differences:
Awake
Start
Awake can't be used as coroutine.

Start can be used as coroutine
Awake is called when the script object is initialised, regardless of whether or not the script is enabled
Start is called on the frame when a script is enabled just before any of the Update methods are called the first time
The Awake function is called on all objects in the Scene before any object's Start function is called. (Remember, objects are instantiated during gameplay, their Awake function is called after the Start functions of Scene objects have already completed.)
Start is called on the frame when a script is enabled just before any of the Update methods are called the first time.


Post a Comment

0 Comments