ZenCoder Lifecycle Methods
ZenCoder supports Unity-style lifecycle methods. You can add them by typing, via IntelliSense, or from the Lifecycle panel.
Execution matches Unity semantics: editor-safe callbacks can run in Edit Mode; all runtime callbacks run in Play Mode.
Signatures below match ZenCoder’s snippets (e.g., Update(float deltaTime)
, FixedUpdate(float fixedDeltaTime)
).
Initialization
Method |
Edit Mode |
Play Mode |
Description |
Awake() |
✅ Yes |
✅ Yes |
Called when the script instance is loaded. |
OnEnable() |
✅ Yes |
✅ Yes |
Called when the object becomes enabled and active. |
OnDisable() |
✅ Yes |
✅ Yes |
Called when the behaviour becomes disabled. |
Start() |
✅ Yes |
✅ Yes |
Called before the first frame update. |
Reset() |
✅ Yes |
✅ Yes |
Resets public variables to default values. |
OnDestroy() |
✅ Yes |
✅ Yes |
Called when the object is destroyed. |
OnValidate() |
✅ Yes |
❌ No |
Called when script properties change in the Inspector. |
Game Loop
Method |
Edit Mode |
Play Mode |
Description |
Update(float deltaTime) |
❌ No |
✅ Yes |
Called once per frame. |
FixedUpdate(float fixedDeltaTime) |
❌ No |
✅ Yes |
Called on a fixed interval, ideal for physics. |
LateUpdate(float deltaTime) |
❌ No |
✅ Yes |
Called after all Update calls. |
Application
Method |
Edit Mode |
Play Mode |
Description |
OnApplicationFocus(bool hasFocus) |
❌ No |
✅ Yes |
Called when the app gains or loses focus. |
OnApplicationPause(bool isPaused) |
❌ No |
✅ Yes |
Called when the app is paused or resumed. |
OnApplicationQuit() |
❌ No |
✅ Yes |
Called before the application quits. |
GUI
Method |
Edit Mode |
Play Mode |
Description |
OnGUI() |
✅ Yes |
✅ Yes |
Handles GUI rendering and input events. |
Gizmos
Method |
Edit Mode |
Play Mode |
Description |
OnDrawGizmos() |
✅ Yes |
✅ Yes |
Draws custom gizmos in the Scene view. |
OnDrawGizmosSelected() |
✅ Yes |
✅ Yes |
Draws gizmos only when the object is selected. |
Visibility
Method |
Edit Mode |
Play Mode |
Description |
OnBecameVisible() |
❌ No |
✅ Yes |
Called when the object becomes visible to a camera. |
OnBecameInvisible() |
❌ No |
✅ Yes |
Called when the object is no longer visible to any camera. |
Method |
Edit Mode |
Play Mode |
Description |
OnTransformChildrenChanged() |
✅ Yes |
✅ Yes |
Called when a child transform changes. |
OnTransformParentChanged() |
✅ Yes |
✅ Yes |
Called when the parent transform changes. |
OnRectTransformDimensionsChange() |
✅ Yes |
✅ Yes |
Called when a RectTransform’s dimensions change. |
Physics 3D
Method |
Edit Mode |
Play Mode |
Description |
OnControllerColliderHit(ControllerColliderHit hit) |
❌ No |
✅ Yes |
Called when a CharacterController hits a collider. |
OnCollisionEnter(Collision collision) |
❌ No |
✅ Yes |
Called when a collision starts. |
OnCollisionStay(Collision collision) |
❌ No |
✅ Yes |
Called every frame while colliding. |
OnCollisionExit(Collision collision) |
❌ No |
✅ Yes |
Called when a collision ends. |
OnTriggerEnter(Collider other) |
❌ No |
✅ Yes |
Called when entering a trigger collider. |
OnTriggerStay(Collider other) |
❌ No |
✅ Yes |
Called every frame while inside a trigger. |
OnTriggerExit(Collider other) |
❌ No |
✅ Yes |
Called when exiting a trigger collider. |
OnJointBreak(float breakForce) |
❌ No |
✅ Yes |
Called when a joint breaks due to force. |
Physics 2D
Method |
Edit Mode |
Play Mode |
Description |
OnCollisionEnter2D(Collision2D collision) |
❌ No |
✅ Yes |
Called when a 2D collision starts. |
OnCollisionStay2D(Collision2D collision) |
❌ No |
✅ Yes |
Called each frame while colliding in 2D. |
OnCollisionExit2D(Collision2D collision) |
❌ No |
✅ Yes |
Called when a 2D collision ends. |
OnTriggerEnter2D(Collider2D other) |
❌ No |
✅ Yes |
Called when entering a 2D trigger collider. |
OnTriggerStay2D(Collider2D other) |
❌ No |
✅ Yes |
Called every frame while inside a 2D trigger. |
OnTriggerExit2D(Collider2D other) |
❌ No |
✅ Yes |
Called when exiting a 2D trigger. |
OnJointBreak2D(Joint2D joint) |
❌ No |
✅ Yes |
Called when a 2D joint breaks. |
Particles
Method |
Edit Mode |
Play Mode |
Description |
OnParticleCollision(GameObject other) |
❌ No |
✅ Yes |
Called when particles hit a collider. |
OnParticleTrigger() |
❌ No |
✅ Yes |
Called when particle system triggers fire. |
OnParticleSystemStopped() |
❌ No |
✅ Yes |
Called when a particle system stops playing. |
OnParticleUpdateJobScheduled() |
❌ No |
✅ Yes |
Called after the particle update job. |
Rendering
Method |
Edit Mode |
Play Mode |
Description |
OnPreCull() |
❌ No |
✅ Yes |
Called before the camera culls the scene. |
OnPreRender() |
❌ No |
✅ Yes |
Called before the camera starts rendering. |
OnPostRender() |
❌ No |
✅ Yes |
Called after the camera has finished rendering. |
OnRenderObject() |
❌ No |
✅ Yes |
Called after all rendering is complete. |
OnRenderImage(RenderTexture src, RenderTexture dest) |
❌ No |
✅ Yes |
Called during post-processing. |
OnWillRenderObject() |
❌ No |
✅ Yes |
Called for each camera that renders the object. |
Animation
Method |
Edit Mode |
Play Mode |
Description |
OnAnimatorMove() |
❌ No |
✅ Yes |
Called after Animator applies root motion. |
OnAnimatorIK(int layerIndex) |
❌ No |
✅ Yes |
Called for setting up inverse kinematics. |
Audio
Method |
Edit Mode |
Play Mode |
Description |
OnAudioFilterRead(float[] data, int channels) |
❌ No |
✅ Yes |
Processes and filters audio data in real time. |
Method |
Edit Mode |
Play Mode |
Description |
OnMouseDown() |
❌ No |
✅ Yes |
Called when the user presses the mouse button over the object. |
OnMouseDrag() |
❌ No |
✅ Yes |
Called while the user drags the mouse over the object. |
OnMouseEnter() |
❌ No |
✅ Yes |
Called when the cursor enters the object. |
OnMouseOver() |
❌ No |
✅ Yes |
Called each frame while the cursor hovers over the object. |
OnMouseExit() |
❌ No |
✅ Yes |
Called when the cursor leaves the object. |
OnMouseUp() |
❌ No |
✅ Yes |
Called when the user releases the mouse button. |
OnMouseUpAsButton() |
❌ No |
✅ Yes |
Called when a full click is completed. |
Notes
- Only methods present in your ZenCoder script are registered and executed.
- Edit Mode execution is limited to Unity’s editor-safe callbacks.
- Lifecycle methods can be added by typing, via IntelliSense, or through the Lifecycle Panel — ZenCoder automatically detects and updates them in real time.