public override void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB) { //if (EditorApplication.isPlayingOrWillChangePlaymode) return; if (_sc == null || (!useRGB && !useAlpha)) { return; } Color currentColor = _sc.TintColor; if (currentColor.Equals(targetColor)) { m_ColorTweenRunner.StopTween(); return; } ColorTween.ColorTweenMode mode = (useRGB && useAlpha ? ColorTween.ColorTweenMode.All : (useRGB ? ColorTween.ColorTweenMode.RGB : ColorTween.ColorTweenMode.Alpha)); var colorTween = new ColorTween { duration = duration, startColor = _sc.TintColor, targetColor = targetColor }; colorTween.AddOnChangedCallback((c) => _sc.TintColor = c); colorTween.ignoreTimeScale = ignoreTimeScale; colorTween.tweenMode = mode; m_ColorTweenRunner.StartTween(colorTween); }
private void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB) { if (canvasRenderer == null || (!useRGB && !useAlpha)) { return; } Color currentColor = canvasRenderer.GetColor(); if (currentColor.Equals(targetColor)) { return; } ColorTween.ColorTweenMode mode = (useRGB && useAlpha ? ColorTween.ColorTweenMode.All : (useRGB ? ColorTween.ColorTweenMode.RGB : ColorTween.ColorTweenMode.Alpha)); var colorTween = new ColorTween { duration = duration, startColor = canvasRenderer.GetColor(), targetColor = targetColor }; colorTween.AddOnChangedCallback(canvasRenderer.SetColor); colorTween.ignoreTimeScale = ignoreTimeScale; colorTween.tweenMode = mode; m_ColorTweenRunner.StartTween(colorTween); }
public void RegisterTweenValueType() { var runner = new TweenRunner(); // Register a test type TweenDataRegistry.RegisterTweenDataType <TestType>(GetValueTestType); // Make sure a tween of that type can be started and updated var startValue = (TestType)1f; var tweenParams = new TweenParams { TweenSecs = 10f, Ease = EaseType.Linear, Loop = LoopType.PingPong }; var tweenRef = runner.StartTween <TestType>( startValue, 10f, tweenParams, null ); // Make sure the starting value is correct var value = runner.GetTweenValue <TestType>(tweenRef); Assert.IsTrue(value == startValue, $"TestType pre update, got value {value} should be {startValue}"); runner.Update(1f / 60f); // Make sure the value has changed after updating value = runner.GetTweenValue <TestType>(tweenRef); Assert.IsTrue(value != startValue, $"TestType post update, got value {value} should be different from start value {startValue}"); runner.StopTween(tweenRef); }
//自身动画 color值变 private void CrossFadeColor(Color startColor, Color targetColor, float duration, bool ignoreTimeScale, bool useAlpha, bool useRGB, UnityAction <Color> callback) { //if (startColor == null || (!useRGB && !useAlpha)) // return; if (!useRGB && !useAlpha) { return; } Color currentColor = startColor; if (currentColor.Equals(targetColor)) { return; } ColorTween.ColorTweenMode mode = (useRGB && useAlpha ? ColorTween.ColorTweenMode.All : (useRGB ? ColorTween.ColorTweenMode.RGB : ColorTween.ColorTweenMode.Alpha)); var colorTween = new ColorTween { duration = duration, startColor = startColor, targetColor = targetColor }; colorTween.AddOnChangedCallback(callback); colorTween.ignoreTimeScale = ignoreTimeScale; colorTween.tweenMode = mode; m_ColorTweenRunner.StartTween(colorTween); }
protected void StartTween(float startFloat, float targetFloat) { float duration = ((!(m_Accordion != null)) ? 0.3f : m_Accordion.transitionDuration); FloatTween floatTween = default(FloatTween); floatTween.duration = duration; floatTween.startFloat = startFloat; floatTween.targetFloat = targetFloat; FloatTween info = floatTween; info.AddOnChangedCallback(SetHeight); info.ignoreTimeScale = true; m_FloatTweenRunner.StartTween(info); }
private void AlphaFadeList(float duration, float start, float end) { if (end.Equals(start)) { return; } FloatTween tween = new FloatTween { duration = duration, startValue = start, targetValue = end }; tween.AddOnChangedCallback(SetAlpha); tween.ignoreTimeScale = true; m_AlphaTweenRunner.StartTween(tween); }
public void CrossFadeFloat(TweenRunner <FloatTween> tweenRunner, float duration, float start, float end, UnityAction <float> callback, UnityAction endCallback) { var floatTween = new FloatTween { duration = duration, startValue = start, targetValue = end }; floatTween.AddOnChangedCallback(callback); if (endCallback != null) { floatTween.AddOnEndCallback(endCallback); } floatTween.ignoreTimeScale = true; tweenRunner.StartTween(floatTween); }
public void CrossFadeVector(TweenRunner <VectorTween> tweenRunner, float duration, Vector3 start, Vector3 end, UnityAction <Vector3> callback, UnityAction endCallback) { var vectorTween = new VectorTween { duration = duration, startValue = start, targetValue = end }; vectorTween.AddOnChangedCallback(callback); if (endCallback != null) { vectorTween.AddOnEndCallback(endCallback); } vectorTween.ignoreTimeScale = true; tweenRunner.StartTween(vectorTween); }
void StartTween(float targetFloat, float duration) { if (_bar == null) { return; } var floatTween = new FloatTween { duration = duration, startFloat = _bar.fillAmount, targetFloat = targetFloat }; floatTween.AddOnChangedCallback(SetFillAmount); floatTween.AddOnFinishCallback(OnTweenFinished); floatTween.ignoreTimeScale = true; floatTween.easing = _easing; m_FloatTweenRunner.StartTween(floatTween); _isTweening = true; }
public void StartAndStopTween() { const int numTweens = 50; var runner = new TweenRunner(); var tweenRefs = new List <TweenRef>(numTweens); // Start a bunch of tweens running var tweenParams = new TweenParams { TweenSecs = 10f, Ease = EaseType.Linear, Loop = LoopType.PingPong }; for (var i = 0; i < numTweens; ++i) { var tweenRef = runner.StartTween( 0f, 10f, tweenParams, null ); tweenRefs.Add(tweenRef); } // Make sure the correct amount started var numRunningTweens = runner.GetNumberOfRunningTweens(); Assert.IsTrue(numRunningTweens == numTweens, $"Only {numRunningTweens} tweens running. We should have started {numTweens}"); // Stop all tweens for (var i = 0; i < tweenRefs.Count; ++i) { runner.StopTween(tweenRefs[i]); } // Make sure they all stopped numRunningTweens = runner.GetNumberOfRunningTweens(); Assert.IsTrue(numRunningTweens == 0, $"There are still {numRunningTweens} tweens running. All should have been stopped"); }