OnDisable() Function in Unity
Notes:
OnDisable() Function in Unity:
8. immediately script is disabled
OnDisable method:
- is called whenever the script gets disabled
- script is disabled when user quits the application, user destroys the object or disables in the inspector or by code.
-is best for any cleanup code
Ex: System.GC.Collect() used to free up unused memory locations
Example code:
void OnDisable()
{
Debug.Log ("OnDisable");
}