/// <summary> /// Starts animating a shadow on or off. /// </summary> /// <param name="set">If true, animate the shadow on. Otherwise animate it off.</param> /// <param name="tweenType">The type of tween curve to use. 'Custom' is not supported.</param> /// <param name="instant">Should the transition be instant and not animate?</param> public void SetShadow(bool set, Tween.TweenType tweenType, bool instant = false) { if (gameObject == null) { return; } isVisible = set; if (set) { gameObject.SetActive(true); } if (Application.isPlaying && !instant) { TweenManager.EndTween(m_Tweener); m_Tweener = TweenManager.TweenFloat(f => canvasGroup.alpha = f, () => canvasGroup.alpha, set ? 1f : 0f, 0.5f, 0f, () => gameObject.SetActive(set), tweenType: tweenType); } else { canvasGroup.alpha = set ? 1f : 0f; gameObject.SetActive(set); } }
/// <summary> /// Starts animating a shadow on or off. /// </summary> /// <param name="set">If true, animate the shadow on. Otherwise animate it off.</param> /// <param name="tweenType">The type of tween curve to use. 'Custom' is not supported.</param> /// <param name="instant">Should the transition be instant and not animate?</param> public void SetShadow(bool set, Tween.TweenType tweenType, bool instant = false) { isVisible = set; if (set) { gameObject.SetActive(true); } if (Application.isPlaying && !instant) { TweenManager.EndTween(m_Tweener); m_Tweener = TweenManager.TweenFloat(f => canvasGroup.alpha = f, () => canvasGroup.alpha, set ? 1f : 0f, 0.5f, 0f, () => { try { gameObject.SetActive(set); } catch (MissingReferenceException e) { } }, tweenType: tweenType); } else { canvasGroup.alpha = set ? 1f : 0f; gameObject.SetActive(set); } }
public DialogAnimatorSlide(float animationDuration, SlideDirection slideInDirection, SlideDirection slideOutDirection, Tween.TweenType slideInTweenType, Tween.TweenType slideOutTweenType) { m_AnimationDuration = animationDuration; m_SlideInDirection = slideInDirection; m_SlideOutDirection = slideOutDirection; m_SlideInTweenType = slideInTweenType; m_SlideOutTweenType = slideOutTweenType; }
public DialogAnimatorSlide(float animationDuration, SlideDirection slideInDirection, SlideDirection slideOutDirection, Tween.TweenType slideInTweenType, Tween.TweenType slideOutTweenType) { m_AnimationDuration = animationDuration; m_SlideInDirection = slideInDirection; m_SlideOutDirection = slideOutDirection; if (slideInTweenType == Tween.TweenType.Custom || slideOutTweenType == Tween.TweenType.Custom) { Debug.LogWarning("Cannot set tween type to 'Custom'"); } else { m_SlideInTweenType = slideInTweenType; m_SlideOutTweenType = slideOutTweenType; } }
public bool AddTween(Transform targetObject, Vector3 startPos, Vector3 endPos, float duration, Tween.TweenType type = Tween.TweenType.Linear, bool removeExisting = true) { var existingTween = GetActiveTween(targetObject); if (existingTween != null) // Tween already exists { if (!removeExisting) { return(false); // Return false and do nothing else if exists and told to not remove } _activeTweensToRemove.Add(existingTween); // Queue removal of existing tween before adding new one } _activeTweensToAdd.Add(new Tween (targetObject, startPos, endPos, Time.time, duration, type)); return(true); }
/// <summary> /// Sets the essential properties that all tweens need and should be called from their constructor. If targetInstanceID is -1 then this tween won't interrupt tweens of the same type on the same target. /// </summary> protected void SetEssentials(Tween.TweenType tweenType, int targetInstanceID, float duration, float delay, bool obeyTimeScale, AnimationCurve curve, Tween.LoopType loop, Action startCallback, Action completeCallback) { this.tweenType = tweenType; this.targetInstanceID = targetInstanceID; if (delay > 0) { Status = Tween.TweenStatus.Delayed; } Duration = duration; Delay = delay; Curve = curve; StartCallback = startCallback; CompleteCallback = completeCallback; LoopType = loop; ObeyTimescale = obeyTimeScale; ResetStartTime(); }
/// <summary> /// Called by TweenManager, initializes the tween. /// </summary> /// <param name="duration">The duration to run the tween, not including delay.</param> /// <param name="delay">The delay that the tween should wait after being created, but before modifying anything.</param> /// <param name="tweenType">The curve type of the tween.</param> /// <param name="callback">The action to call once the tween has finished.</param> /// <param name="animationCurve">TODO</param> /// <param name="scaledTime">Should the tween factor in Time.timeScale when running?</param> /// <param name="id">Used by TweenManager to identify the tween. Unique for each and every AutoTween.</param> public void Initialize(float duration, float delay, Tween.TweenType tweenType, Action callback, AnimationCurve animationCurve, bool scaledTime, int id) { m_Duration = duration; m_Delay = delay; m_TweenType = tweenType; m_Callback = callback; m_CustomCurve = animationCurve; m_ScaledTime = scaledTime; m_TweenId = id; if (m_Delay > 0) { m_WaitingForDelay = true; } else { m_WaitingForDelay = false; StartTween(); } m_Active = true; }
public void Initialize(float duration, float delay, Tween.TweenType tweenType, Action callback, AnimationCurve animationCurve, bool scaledTime, int id) { m_Duration = duration; m_Delay = delay; m_TweenType = tweenType; m_Callback = callback; m_CustomCurve = animationCurve; m_ScaledTime = scaledTime; m_TweenId = id; if (m_Delay > 0) { m_WaitingForDelay = true; } else { m_WaitingForDelay = false; StartTween(); } m_Active = true; }
/// <summary> /// Initializes the specified update value. /// </summary> /// <param name="updateValue">The update value.</param> /// <param name="startValue">The start value.</param> /// <param name="targetValue">The target value.</param> /// <param name="duration">The duration.</param> /// <param name="delay">The delay.</param> /// <param name="tweenType">Type of the tween.</param> /// <param name="callback">The callback.</param> /// <param name="animationCurve">The animation curve.</param> /// <param name="scaledTime">if set to <c>true</c> [scaled time].</param> /// <param name="id">The identifier.</param> public void Initialize(Action <Color> updateValue, Func <Color> startValue, Func <Color> targetValue, float duration, float delay, Tween.TweenType tweenType, Action callback, AnimationCurve animationCurve, bool scaledTime, int id) { m_GetStartValue = startValue; m_UpdateValue = updateValue; m_GetTargetValue = targetValue; Initialize(duration, delay, tweenType, callback, animationCurve, scaledTime, id); }
public static DialogAnimatorSlide AddOrSetupDialogAnimatorSlide(MaterialDialogCompat materialDialog, float animationDuration, SlideDirection slideInDirection, SlideDirection slideOutDirection, Tween.TweenType slideInTweenType, Tween.TweenType slideOutTweenType) { var animator = GetOrAddTypedDialogAnimator <DialogAnimatorSlide>(materialDialog); if (animator != null) { animator.m_AnimationDuration = animationDuration; animator.m_SlideInDirection = slideInDirection; animator.m_SlideOutDirection = slideOutDirection; if (slideInTweenType == Tween.TweenType.Custom || slideOutTweenType == Tween.TweenType.Custom) { Debug.LogWarning("Cannot set tween type to 'Custom'"); } else { animator.m_SlideInTweenType = slideInTweenType; animator.m_SlideOutTweenType = slideOutTweenType; } } return(animator); }
public static int TweenColor(Action <Color> updateValue, Func <Color> startValue, Func <Color> targetValue, float duration, float delay = 0f, Action callback = null, bool scaledTime = false, Tween.TweenType tweenType = Tween.TweenType.EaseOutQuint) { #if UNITY_EDITOR if (!Application.isPlaying) { return(-2); } #endif AutoTweenColor tween = instance.m_TweenColorQueue.GetTween(); int id = instance.m_TweenIdCount; instance.m_TweenIdCount++; tween.Initialize(updateValue, startValue, targetValue, duration, delay, tweenType, callback, null, scaledTime, id); instance.m_ActiveTweens.Add(tween); return(id); }
public static int TweenColor(Action <Color> updateValue, Func <Color> startValue, Color targetValue, float duration, float delay = 0f, Action callback = null, bool scaledTime = false, Tween.TweenType tweenType = Tween.TweenType.EaseOutQuint) { return(TweenColor(updateValue, startValue, () => targetValue, duration, delay, callback, scaledTime, tweenType)); }
public static int TweenVector4(Action <Vector4> updateValue, Vector4 startValue, Vector4 targetValue, float duration, float delay = 0f, Action callback = null, bool scaledTime = false, Tween.TweenType tweenType = Tween.TweenType.EaseOutQuint) { return(TweenVector4(updateValue, () => startValue, () => targetValue, duration, delay, callback, scaledTime, tweenType)); }
public static int TweenValue <T>(Action <T> updateValue, Func <T> startValue, Func <T> targetValue, float duration, float delay = 0f, Action callback = null, bool scaledTime = false, Tween.TweenType tweenType = Tween.TweenType.EaseOutQuint) { if (typeof(T) == typeof(float)) { return(TweenFloat(updateValue as Action <float>, startValue as Func <float>, targetValue as Func <float>, duration, delay, callback, scaledTime, tweenType)); } else if (typeof(T) == typeof(int)) { return(TweenInt(updateValue as Action <int>, startValue as Func <int>, targetValue as Func <int>, duration, delay, callback, scaledTime, tweenType)); } else if (typeof(T) == typeof(Vector2)) { return(TweenVector2(updateValue as Action <Vector2>, startValue as Func <Vector2>, targetValue as Func <Vector2>, duration, delay, callback, scaledTime, tweenType)); } else if (typeof(T) == typeof(Vector3)) { return(TweenVector3(updateValue as Action <Vector3>, startValue as Func <Vector3>, targetValue as Func <Vector3>, duration, delay, callback, scaledTime, tweenType)); } else if (typeof(T) == typeof(Vector4)) { return(TweenVector4(updateValue as Action <Vector4>, startValue as Func <Vector4>, targetValue as Func <Vector4>, duration, delay, callback, scaledTime, tweenType)); } else if (typeof(T) == typeof(Color)) { return(TweenColor(updateValue as Action <Color>, startValue as Func <Color>, targetValue as Func <Color>, duration, delay, callback, scaledTime, tweenType)); } else { Debug.LogWarning("Value type not supported for tweening"); return(0); } }