Site icon Teaching Newbies since 2014

Unity3D Scripting API #9: OnDisable() 🛡

Unity3D Scripting API

Unity3D Scripting API

https://www.youtube.com/watch?v=-OqjXuDBDOc&t=3s

⭐ OnDisable()

🛡️Called whenever the script component is disabled
🛡️ Also called when a game object is destroyed. When you quit your game, the scripts (which are game objects) are destroyed and this triggers the OnDisable() event method
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CubeController : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        Debug.Log("Start");
    }
    void Update()
    {

    }
    void OnDisable()
    {
        Debug.Log("On Disable");

    }
}
Exit mobile version