public override void Play <T>(T from, T to, TransitionComplete onTransitionComplete)
 {
     if (from != null)
     {
         from.TransitionOut(onTransitionComplete);
     }
     if (to != null)
     {
         to.TransitionIn(onTransitionComplete);
     }
 }
        public override void Play <T>(T from, T to, TransitionComplete onTransitionComplete)
        {
            if (from != null)
            {
                this._from = from as SimpleScreen;
                this._from.CanvasGroup.alpha = 1f;
            }
            if (to != null)
            {
                this._to = to as SimpleScreen;
                this._to.CanvasGroup.alpha = 0f;
            }
            this._onTransitionComplete = onTransitionComplete;

            Play();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Called when animation is complete
        /// Calls and resets callbacks, if any
        /// </summary>
        private void DismissAnim()
        {
            CurrentAnimName = "";

            if (AnimFinishedCallback != null)
            {
                AnimFinishedCallback();
                AnimFinishedCallback = null;
            }

            if (OnTransitionComplete != null)
            {
                OnTransitionComplete();
                OnTransitionComplete = null;
            }
        }
Exemplo n.º 4
0
    private IEnumerator Transition(Vector3 target, AnimationCurve curve, JobHandle handle)
    {
        yield return(new WaitForSeconds(m_delay));

        Vector3 start = transform.position;
        float   time  = 0.0f;

        while (time < m_transitionTime)
        {
            time += Time.deltaTime;
            float t = curve.Evaluate(Mathf.Clamp01(time / m_transitionTime));
            transform.position = Vector3.LerpUnclamped(start, target, t);
            yield return(null);
        }

        TransitionComplete?.Invoke();
        handle.Complete();
    }
Exemplo n.º 5
0
        /// <summary>
        /// Starts transition to invisible
        /// </summary>
        /// <param name="onTransitionComplete">Callback for when transition is complete</param>
        public override void TransitionOut(TransitionComplete onTransitionComplete)
        {
            Disable();

            CurrentAnimName = "Out";

            AnimFinishedCallback = Hide;

            this.OnTransitionComplete = onTransitionComplete;

            if (enabled)
            {
                PlayAnim();
            }
            else
            {
                DismissAnim();
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Starts transition to vsibile
        /// </summary>
        /// <param name="onTransitionComplete">Callback for when transition is complete</param>
        public override void TransitionIn(TransitionComplete onTransitionComplete)
        {
            Show();
            Disable();

            CurrentAnimName = "In";

            AnimFinishedCallback = Enable;

            this.OnTransitionComplete = onTransitionComplete;

            if (Animator != null)
            {
                PlayAnim();
            }
            else
            {
                DismissAnim();
            }
        }
Exemplo n.º 7
0
    public static IEnumerator FadeCoroutine(float startAlpha, float endAlpha, float duration,
                                            CanvasGroup canvas, TransitionComplete callback)
    {
        Assert.IsTrue(duration >= 0.0F);
        float elapsedTime = 0.0F;

        while (elapsedTime < duration)
        {
            canvas.alpha = Mathf.Lerp(startAlpha, endAlpha, elapsedTime / duration);
            yield return(new WaitForEndOfFrame());

            elapsedTime += Time.unscaledDeltaTime;
        }

        canvas.alpha = endAlpha;

        yield return(new WaitForEndOfFrame());

        if (callback != null)
        {
            callback();
        }
    }
 private void Reset()
 {
     _from = _to = null;
     _onTransitionComplete = null;
 }
Exemplo n.º 9
0
 /// <summary>
 /// For playing individual transition ending in screen being invsible and inactive
 /// </summary>
 /// <param name="onTransitionComplete">Should be called when the transition is complete</param>
 public abstract void TransitionOut(TransitionComplete onTransitionComplete);
Exemplo n.º 10
0
 public abstract void Play <T>(T from, T to, TransitionComplete onTransitionComplete) where T : BaseScreen;
Exemplo n.º 11
0
        /// <summary>
        /// Called when animation is complete
        /// Calls and resets callbacks, if any
        /// </summary>
        private void DismissAnim()
        {
            CurrentAnimName = "";

            if (AnimFinishedCallback != null)
            {
                AnimFinishedCallback();
                AnimFinishedCallback = null;
            }

            if (OnTransitionComplete != null)
            {
                OnTransitionComplete();
                OnTransitionComplete = null;
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Starts transition to invisible
        /// </summary>
        /// <param name="onTransitionComplete">Callback for when transition is complete</param>
        public override void TransitionOut(TransitionComplete onTransitionComplete)
        {
            Disable();

            CurrentAnimName = "Out";

            AnimFinishedCallback = Hide;

            this.OnTransitionComplete = onTransitionComplete;

            if (enabled)
            {
                PlayAnim();
            }
            else
                DismissAnim();
        }
Exemplo n.º 13
0
        /// <summary>
        /// Starts transition to vsibile
        /// </summary>
        /// <param name="onTransitionComplete">Callback for when transition is complete</param>
        public override void TransitionIn(TransitionComplete onTransitionComplete)
        {
            Show();
            Disable();

            CurrentAnimName = "In";

            AnimFinishedCallback = Enable;

            this.OnTransitionComplete = onTransitionComplete;

            if (Animator != null)
            {
                PlayAnim();
            }
            else
            {
                DismissAnim();
            }
        }