protected virtual void OnDestroy() // should be called in derived class { if (isSingletonObject) { UnitySingleton <T> ._Destroy(); } }
protected virtual void Awake() // should be called in derived class { if (isSingletonObject) { #if UNITY_FLASH UnitySingleton <T> ._Awake(this); #else UnitySingleton <T> ._Awake(this as T); #endif //Debug.Log( "Awake: " + this.GetType().Name ); } }
/// <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); }
/// <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)); }