Event Functions
Event Functions are special functions automatically called during the Life Cycle of a GameObject or component in the Unity engine, Therefore, they are also referred to as Lifecycle Event Functions.
Event Functions are automatically called by the Unity engine at specific timings.
Event Functions are special functions automatically called during the Life Cycle of a GameObject or component in the Unity engine, hence they are also referred to as Lifecycle Event Functions.
- You can use an initialization event to call the initialization code before an update.
- The Start function is called before any physics update and before the first frame, while the Awake function is called for each object in the scene when calling up a scene.
- Start and Awake functions for various objects are called in random order, but all Awake calls are finished before Start is called.
- This means that the Start function can use other initializations previously carried out in the Awake function.
- Regular updates refers to all updates called every frame.
- They change the position, state, and behavior of objects before each frame is rendered.
- ZEPETOScript provides a guideline for processing the computation in the Update function.
- Physics events call event functions through a script added in the GameObject.
- The OnCollisionEnter, OnCollisionStay, and OnCollisionExit functions are called as contact is made, held, and broken.
- The OnTriggerEnter, OnTriggerStay and OnTriggerExit functions are called when an object collider is configured as a trigger (i.e. a collider that does not react physically to collisions but simply detects them instead).
- Such functions may be called several times in succession if multiple contacts are detected during the physics update, and thus parameters are sent to the function that provides details of the collision (position, identity of the object).
- ZEPETOScript supports events that render GUI controls and reacts to clicks from the elements. They work differently from normal frame updates, so UI related logic should be placed in the OnGUI function.
- In ZEPETOScript, events that respond to mouse interactions are supported.
- However, mouse events require a Collider or Collider2D to be present on the relevant GameObject, and they are only triggered when that Collider is clicked with the mouse.
- OnMouseDown() is called when the user clicks the mouse button.
- OnMouseUp() is called when the user releases the mouse button.
- OnMouseOver() is called every frame while the mouse cursor is over the Collider or Collider2D of the GameObject.
- Termination events are called in all activated objects in a scene.
- The OnDisable function is called when a given object is disabled or is inactive, and OnApplicationQuit is called on all GameObjects before the application closes.
📘 Unity Event Functions https://docs.unity3d.com/kr/current/Manual/EventFunctions.html
All the event functions inherently supported by ZEPETOScript are listed in the sample code below.
Check out the test code output screen below.
You can learn more about the Unity event functions that ZEPETOScript offers by clicking the links below.
📘 Order of Execution for Event Functions https://docs.unity3d.com/kr/current/Manual/ExecutionOrder.html