Skip to content

Instantly share code, notes, and snippets.

@suakig
Created May 9, 2015 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suakig/5c47ec24717f73f7d98f to your computer and use it in GitHub Desktop.
Save suakig/5c47ec24717f73f7d98f to your computer and use it in GitHub Desktop.
EndMonoBehaviour.cs
using UnityEngine;
using System.Collections;
public class EndMonoBehaviour : MonoBehaviour
{
bool isApplicationQuit = false;
private void OnApplicationQuit()
{
isApplicationQuit = true;
}
private void OnDisable()
{
if (isApplicationQuit) {
return;
}
OnDisableNotApplicationQuit ();
}
private void OnDestroy()
{
if (isApplicationQuit) {
return;
}
OnDestroyNotApplicationQuit ();
}
protected virtual void OnDisableNotApplicationQuit (){}
protected virtual void OnDestroyNotApplicationQuit (){}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment