The primary means of scripting in Unity is to write callback functions in classes derived from MonoBehaviour
, which we know Unity will call when necessary. Perhaps the four most commonly used callbacks are Awake()
, Start()
, Update()
, and FixedUpdate()
.
Awake()
is called the moment a MonoBehaviour
is first created, whether this occurs during Scene initialization or when a new GameObject
containing the MonoBehaviour
is instantiated at runtime from a Prefab. Start()
will be called shortly after Awake()
but before its first Update()
. During Scene initialization, every MonoBehaviour
Component's Awake()
callback will be called before any of their Start()
callbacks are.
After this, Update()
will be called repeatedly, each time the Rendering Pipeline presents a new image. Update()
will continue to be called provided the MonoBehaviour
is still present in the Scene, it is still enabled, and its parent GameObject
is active.
Finally, FixedUpdate()
is called just prior...