/// <summary> /// Starts the transition. /// </summary> public void Start() { if (_isStarted) { return; } _isStarted = true; // Transition not required if (_elementA == null && _elementB == null) { OnHide.InvokeIfNotNull(); OnComplete.InvokeIfNotNull(); return; } // Nothing to show if (_elementA != null && _elementB == null) { ElementAHide(); return; } // Nothing to hide if (_elementA == null && _elementB != null) { ElementBShow(); return; } float hideDuration = _elementA.GetAnimationHideDuration(); if (_offsetTime <= 0 || hideDuration <= 0) { ElementAHideWithoutCallback(); ElementBShow(); } else if (_offsetTime >= 1) { ElementAHide(); } else { ElementAHideWithoutCallback(); new DeferredAction ( ElementBShow, hideDuration * _offsetTime, DeferredType.TimeBased ); } }
// ElementA hide completed private void ElementAHideCompleted() { OnHide.InvokeIfNotNull(); _elementA.OnHide -= ElementAHideCompleted; if (_elementB == null) { OnComplete.InvokeIfNotNull(); } else { ElementBShow(); } }
/// <summary> /// Performed when Hide processes completed. /// In inherited classes always use base.HideEnd() when overriding this method. /// </summary> protected virtual void HideEnd() { OnHide.InvokeIfNotNull(); SetActive(false); }
// ElementA hide completed private void ElementAHideWithoutCallbackCompleted() { OnHide.InvokeIfNotNull(); _elementA.OnHide -= ElementAHideWithoutCallbackCompleted; }