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(); }
/// <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; } }
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(); }
/// <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(); } }
/// <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(); } }
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; }
/// <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);
public abstract void Play <T>(T from, T to, TransitionComplete onTransitionComplete) where T : BaseScreen;
/// <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(); }