Exemplo n.º 1
0
        /// <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
                );
            }
        }
Exemplo n.º 2
0
        // ElementA hide completed
        private void ElementAHideCompleted()
        {
            OnHide.InvokeIfNotNull();

            _elementA.OnHide -= ElementAHideCompleted;

            if (_elementB == null)
            {
                OnComplete.InvokeIfNotNull();
            }
            else
            {
                ElementBShow();
            }
        }
Exemplo n.º 3
0
        /// <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;
        }
Exemplo n.º 4
0
        // ElementB show completed
        private void ElementBShowCompleted()
        {
            _elementB.OnShow -= ElementBShowCompleted;

            OnComplete.InvokeIfNotNull();
        }