public void Initialize(ITweenTarget <T> target, T to, float duration) { Reset(); this.target = target; this.toValue = to; this.duration = duration; }
public virtual void recycleSelf() { if (_shouldRecycleTween) { _target = null; _nextTween = null; } }
public virtual void RecycleSelf() { if (shouldRecycleTween) { target = null; nextTween = null; } }
/// <summary> /// resets all state to defaults and sets the initial state based on the paramaters passed in. This method serves /// as an entry point so that Tween subclasses can call it and so that tweens can be recycled. When recycled, /// the constructor will not be called again so this method encapsulates what the constructor would be doing. /// </summary> /// <param name="target">Target.</param> /// <param name="from">From.</param> /// <param name="to">To.</param> /// <param name="duration">Duration.</param> public void initialize(ITweenTarget <T> target, T to, float duration) { // reset state in case we were recycled resetState(); _target = target; _toValue = to; _duration = duration; }
public IntTween(ITweenTarget <int> target, int from, int to, float duration) { initialize(target, from, to, duration); }
public QuaternionTween(ITweenTarget <Quaternion> tweenTarget, Quaternion toValue, float duration) : base(tweenTarget, toValue, duration) { }
public Vector2Tween(ITweenTarget <Vector2> target, Vector2 from, Vector2 to, float duration) { initialize(target, from, to, duration); }
public Color32Tween(ITweenTarget <Color32> target, Color32 from, Color32 to, float duration) { initialize(target, from, to, duration); }
public RectTween(ITweenTarget <Rect> target, Rect to, float duration) { Initialize(target, to, duration); }
public Vector3Tween(ITweenTarget <Vector3> target, Vector3 from, Vector3 to, float duration) { Initialize(target, to, duration); }
public ColorTween(ITweenTarget <Color> tweenTarget, Color toValue, float duration) : base(tweenTarget, toValue, duration) { }
public RectangleTween(ITweenTarget <Rectangle> tweenTarget, Rectangle toValue, float duration) : base(tweenTarget, toValue, duration) { }
public Vector2Tween(ITweenTarget <System.Numerics.Vector2> target, System.Numerics.Vector2 to, float duration) { Initialize(target, to, duration); }
public IntTween(ITweenTarget <int> tweenTarget, int toValue, float duration) : base(tweenTarget, toValue, duration) { }
public QuaternionTween(ITweenTarget <Quaternion> target, Quaternion from, Quaternion to, float duration) { initialize(target, from, to, duration); }
public ColorTween(ITweenTarget <Color> target, Color from, Color to, float duration) { initialize(target, from, to, duration); }
public bool tick() { if (_tweenState == TweenState.Paused) { return(false); } // when we loop we clamp values between 0 and duration. this will hold the excess that we clamped off so it can be reapplied var elapsedTimeExcess = 0f; if (!_isRunningInReverse && _elapsedTime >= _duration) { elapsedTimeExcess = _elapsedTime - _duration; _elapsedTime = _duration; _tweenState = TweenState.Complete; } else if (_isRunningInReverse && _elapsedTime <= 0) { elapsedTimeExcess = 0 - _elapsedTime; _elapsedTime = 0f; _tweenState = TweenState.Complete; } // elapsed time will be negative while we are delaying the start of the tween so dont update the value if (_elapsedTime >= 0 && _elapsedTime <= _duration) { updateValue(); } // if we have a loopType and we are Complete (meaning we reached 0 or duration) handle the loop. // handleLooping will take any excess elapsedTime and factor it in and call udpateValue if necessary to keep // the tween perfectly accurate. if (_loopType != LoopType.None && _tweenState == TweenState.Complete && _loops > 0) { handleLooping(elapsedTimeExcess); } var deltaTime = _isTimeScaleIndependent ? Time.unscaledDeltaTime : Time.deltaTime; deltaTime *= _timeScale; // running in reverse? then we need to subtract deltaTime if (_isRunningInReverse) { _elapsedTime -= deltaTime; } else { _elapsedTime += deltaTime; } if (_tweenState == TweenState.Complete) { if (_completionHandler != null) { _completionHandler(this); } // if we have a nextTween add it to ZestKit so that it can start running if (_nextTween != null) { _nextTween.start(); _nextTween = null; } if (ticker != null) { StopTicker(); _target = null; } return(true); } return(false); }
public FloatTween(ITweenTarget <float> target, float from, float to, float duration) { initialize(target, from, to, duration); }
public Vector4Tween(ITweenTarget <Vector4> tweenTarget, Vector4 toValue, float duration) : base(tweenTarget, toValue, duration) { }
public FloatTween(ITweenTarget <float> tweenTarget, float toValue, float duration) : base(tweenTarget, toValue, duration) { }
public Vector4Tween(ITweenTarget <Vector4> target, Vector4 to, float duration) { Initialize(target, to, duration); }
public RectangleTween(ITweenTarget <Rectangle> target, Rectangle to, float duration) { Initialize(target, to, duration); }
protected Tween(ITweenTarget <T> tweenTarget, T toValue, float duration) { this.TweenTarget = tweenTarget; this.ToValue = toValue; this.Duration = duration; }