Example #1
0
 private void Awake()
 {
     if (SingletonMono <T, V> .m_instance == null)
     {
         object lockBoo = SingletonMono <T, V> .m_lockBoo;
         Monitor.Enter(lockBoo);
         try
         {
             if (SingletonMono <T, V> .m_instance == null)
             {
                 SingletonMono <T, V> .setDontDestroy(base.gameObject);
             }
             else
             {
                 Debug.LogError("destroy one singleton component in " + base.gameObject.name + ",please remove the component " + typeof(T).ToString());
                 UnityEngine.Object.Destroy(base.gameObject.GetComponent <T>());
             }
         }
         finally
         {
             Monitor.Exit(lockBoo);
         }
     }
     else
     {
         UnityEngine.Object.Destroy(base.gameObject);
     }
 }