Exemplo n.º 1
0
 protected virtual void Awake()
 {
     if (_instance != null)
     {
         Debug.LogError("MonoSingleton [" + _instance.ToString() + "] allready exist");
         Destroy(this);
     }
     _instance = GetComponent <T>();
     if (dontDestroyOnLoad)
     {
         DontDestroyByLoad.EnableDontDestroyOnLoad(gameObject);
     }
     gameObject.SetActive(!hideAtLaunch);
 }
Exemplo n.º 2
0
 protected virtual void OnDestroy()
 {
     _instance = default;
     DontDestroyByLoad.OnDestroyObj(gameObject);
 }