Version: 5.4

Descripción

Esta función se llama cuando el comportamiento se desactiva () o inactivo.

This is also called when the object is destroyed and can be used for any cleanup code. When scripts are reloaded after compilation has finished, OnDisable will be called, followed by an OnEnable after the script has been loaded.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { void OnDisable() { print("script was removed"); } }

OnDisable no puede ser una co-routine.