Beispiel #1
0
 public static void Disable()
 {
     if (_instance != null)
     {
         GameObject.Destroy(_instance.gameObject);
         _instance = null;
     }
 }
Beispiel #2
0
 void OnDestroy()
 {
     if (this == _instance)
     {
         _instance = null;
         toasts.Clear();
     }
 }
Beispiel #3
0
 // call Initialize() when the app loads.  This will create the singleton game object.
 public static void Initialize()
 {
     if (_instance == null)
     {
         GameObject go = new GameObject("ToastCenter");
         _instance = go.AddComponent <ToastCenter>(); // will finish initializing in OnEnable()
     }
 }
Beispiel #4
0
 void OnEnable()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(gameObject);
         return;
     }
     if (_instance == null)
     {
         _instance = this;
         _instance.InitInternal();
         DontDestroyOnLoad(_instance.gameObject);
     }
 }