Class TweenBase<TTarget, TParameter>
- Namespace
- Fallencake.UI
- Assembly
- Fallencake.UI.dll
Generic base for strongly-typed tweens that animate a target from a start value to an end value.
public abstract class TweenBase<TTarget, TParameter> : ITargetableTween<TTarget, TParameter>, ITween
Type Parameters
TTargetType of animated target component.
TParameterType of tweened parameter.
- Inheritance
-
objectTweenBase<TTarget, TParameter>
- Implements
-
ITargetableTween<TTarget, TParameter>
- Derived
Fields
_delay
[SerializeField]
protected float _delay
Field Value
- float
_duration
[SerializeField]
protected float _duration
Field Value
- float
_ease
[SerializeField]
protected AnimationCurve _ease
Field Value
- AnimationCurve
_endValue
[SerializeField]
protected TParameter _endValue
Field Value
- TParameter
_isTweened
protected bool _isTweened
Field Value
- bool
_startValue
[SerializeField]
protected TParameter _startValue
Field Value
- TParameter
_target
[SerializeField]
protected TTarget _target
Field Value
- TTarget
_tweenCoroutine
protected Coroutine _tweenCoroutine
Field Value
- Coroutine
Properties
Delay
Delay before the tween starts, in seconds.
public float Delay { get; set; }
Property Value
- float
Duration
Total duration of the tween, in seconds.
public float Duration { get; set; }
Property Value
- float
Ease
Easing curve used to interpolate between values.
public AnimationCurve Ease { get; }
Property Value
- AnimationCurve
EndValue
End value used when playing forward.
public TParameter EndValue { get; }
Property Value
- TParameter
IsTweened
Whether this tween has completed at least one play.
public bool IsTweened { get; }
Property Value
- bool
StartValue
Start value used when playing backward or for immediate resets.
public TParameter StartValue { get; }
Property Value
- TParameter
Target
The target component animated by this tween.
public TTarget Target { get; }
Property Value
- TTarget
Methods
ApplyEndValueInstant()
Instantly applies the end value to the target without animation.
protected abstract void ApplyEndValueInstant()
GetTargetValue(bool)
Returns the value that should be applied to the target based on direction.
protected TParameter GetTargetValue(bool isForward)
Parameters
isForwardboolDirection flag passed to Play(MonoBehaviour, bool).
Returns
- TParameter
OnComplete()
Marks the tween as completed; typically called at the end of Play.
protected void OnComplete()
OnStart()
Called at the start of Play to reset the tween state. Derived classes should call this before starting their animation.
protected void OnStart()
Play(MonoBehaviour, bool)
Plays the tween on a coroutine holder. Implementations should start a coroutine and call OnComplete() when finished.
public abstract void Play(MonoBehaviour coroutineHolder, bool isForward = true)
Parameters
coroutineHolderMonoBehaviourMonoBehaviour used to start/stop coroutines.
isForwardboolIf true plays towards EndValue, otherwise towards StartValue.
Reset(bool)
Resets tween state; optionally resets the target to the start value.
public void Reset(bool isResetTarget)
Parameters
isResetTargetboolIf true, calls ResetTarget().
ResetTarget()
Implemented by concrete tweens to restore target to its initial state.
protected abstract void ResetTarget()
SetToEndValue()
Public method to instantly apply the end value. Marks tween as completed.
public void SetToEndValue()