Skip to content

Instantly share code, notes, and snippets.

@TocaLucas
Last active December 22, 2015 17:28
Show Gist options
  • Save TocaLucas/6506229 to your computer and use it in GitHub Desktop.
Save TocaLucas/6506229 to your computer and use it in GitHub Desktop.
SingleBehaviour
using UnityEngine;
using System.Collections;
public class SingleBehaviour<T> : MonoBehaviour where T : MonoBehaviour {
private static T _instance;
public static T Instance {
get {
return _instance;
}
}
protected void OnEnable() {
_instance = this as T;
}
protected void OnDisable() {
_instance = null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment