コード例 #1
0
 protected virtual void OnDestroy()  // should be called in derived class
 {
     if (isSingletonObject)
     {
         UnitySingleton <T> ._Destroy();
     }
 }
コード例 #2
0
        protected virtual void Awake() // should be called in derived class
        {
            if (isSingletonObject)
            {
                UnitySingleton <T> ._Awake(this as T);

                //Debug.Log( "Awake: " + this.GetType().Name );
            }
        }
コード例 #3
0
 /// <summary>
 /// Activates the singleton instance.
 /// </summary>
 /// <remarks>
 /// Call this function if you set an singleton object inactive before ever accessing the <c>Instance</c>. This is
 /// required because Unity does not (yet) offer a way to find inactive game objects.
 /// </remarks>
 static public void ActivateSingletonInstance() //
 {
     UnitySingleton <T> .GetSingleton(true, true);
 }
コード例 #4
0
 /// <summary>
 /// Checks if an instance of this MonoBehaviour exists.
 /// </summary>
 /// <returns>
 /// A reference to the instance if it exists, otherwise <c>null</c>
 /// </returns>
 static public T DoesInstanceExist()
 {
     return(UnitySingleton <T> .GetSingleton(false, false));
 }