Version: 2017.1

Descripción

Esta función se llama cuando el objeto scriptable se va fuera del alcance (scope).

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.