/// <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> /// Stops all playing animation clips that were started with this UiAnimation. /// </summary> public void Stop(bool gotoLastFrame = true) { if (!IsPlaying || _activeAnimation == null) { return; } if (gotoLastFrame) { _activeAnimation.RewindToEnd(); } OnComplete.InvokeIfNotNull(_activeAnimation); IsPlaying = false; Time = 0; _activeAnimation = null; }
// ElementB show completed private void ElementBShowCompleted() { _elementB.OnShow -= ElementBShowCompleted; OnComplete.InvokeIfNotNull(); }