OnDestroy() Function in Unity

Notes:

OnDestroy() Function in Unity:

9. objects are destroyed

OnDestroy method:
- is called when object is about to destroy
- is called when current scene ends or unloaded
- is called after game application quits
- is called when user stops play mode in the Unity Editor.

- is best for coding when object is about to destroy
Ex: instantiating a blast effect when grenade is about to destroy

Example code:

void OnDestroy()
{
Debug.Log ("OnDestroy");
}