protected void Awake() { if (instance == null) { instance = SingletonUtil.Get <TSingleton> (); } if (instance != null) { if (this != instance) { DestroyDuplicate(); return; } } else { instance = this as TSingleton; if (!isCreatedByProvider) { SingletonUtil.Bind(instance); SingletonUtil.CallOnCreateIfPossible(instance); } } isOnDestroying = false; if (IsGlobal) { DontDestroyOnLoad(this); } SingletonUtil.CallOnAwakeIfPossible(instance); }
protected void OnDestroy() { if (this != instance) { return; } SingletonUtil.CallOnDestroyIfPossible(instance); SingletonUtil.Unbind(instance); instance = null; isOnDestroying = true; isCreatedByProvider = false; }