Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public abstract class SingletonBehaviour<T> : MonoBehaviour
  4. where T : SingletonBehaviour<T>{
  5. public static T Instance { get; private set; }
  6.  
  7. void Awake(){
  8. if(Instance == null){
  9. Instance = this as T;
  10. onAwake();
  11. }
  12. else Destroy(this);
  13. }
  14.  
  15. protected virtual void onAwake(){ }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement