If you are at least a little bit familiar with Unity3d you should probably deal with such basic event methods as Start() and Update(). But there is much more events that can be manipulated in your scripts.
Scripts created in Unity editor are inherited from MonoBehavior class by default. This class has all event methods that can be overridden in your script. These methods are logically separated by groups.
Unity basic event methods groups
- Input events
- Game logic
- Scene rendering
- Gizmo rendering
- GUI rendering
- End of frame
Here we list the basic event groups.
Awake() – called before prefab is instantiated. Notice, that Awake won’t be called if object is not active.
OnEnable() – called when object becomes enabled (when level is loaded or GameObject is created). Is not called if object is not active.
Both Awake() and OnEnable() methods are called before Start/Update methods of any other script.
Start() – called before the Update() method. Used for data initialization.
Update event methods order
FixedUpdate() – like Update(), is called every frame. Used for physics psrocessing.
Update() – called every frame. Is used for dynamic data update between frames.
LateUpdate() – called right after Update() methods.
OnTriggerXXX – called if object’s collider collides with a trigger.
OnCollisionXXX – called called if object’s collider collides with another collider.
XXX means different variations like OnCollisionEnter, OnCollisionExit, OnCollisionStay, etc.
OnDestroy – called after last object update before being destroyed.
OnApplicationQuit – called before application is quit (or when in editor user stops Game mode).
OnDisable – called when object becomes disabled or inactive.
Unity3d basic methods lifecycle