Menu
CoddyTech

Recap: Lifecycle Logger

Part of the Unity Scripting Basics section of Coddy's Unity journey. Lesson 74 of 85.

This recap puts the chapter together: every method Unity calls on a script, from Awake() to OnDestroy(), in the order it calls them.

challenge icon

Challenge

Medium

Show Unity's order in the Console.

  1. Write Awake, OnEnable, Start, OnDisable and OnDestroy, each logging its own name.
  2. Write FixedUpdate, Update and LateUpdate the same way, logging only on the first call, with a bool field each.
  3. In Update(), on Space, call Destroy(gameObject);.

Press Play, then Space: the Console lists the eight names in order. Then Check.

Try it yourself

using UnityEngine;

public class LifecycleLogger : MonoBehaviour
{
    // Log each method's name: Awake, OnEnable, Start, FixedUpdate, Update,
    // LateUpdate, OnDisable, OnDestroy. The three that repeat log only once.
    // Space destroys this object.
}
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Unity Scripting Basics

Practice on your own: Unity playground