Class Tween<T>
Base class for anything you want to tween via inspector.
Inheritance
Implements
Inherited Members
Namespace: GGL.Animation
Assembly: GGL.dll
Syntax
[HelpURL("https://ggl.yoannhaffner.com/articles/tweens.html#creer-votre-propre-composant-tweent")]
public abstract class Tween<T> : TriggerBehaviour, ITriggerState where T : Component
Type Parameters
Name | Description |
---|---|
T | Target type |
Remarks
To learn how to properly inherit this class, check the HelpURL attribute.
Fields
| Edit this page View Sourcedelay
Declaration
[SerializeField]
[Tooltip("Delay before starting the animation once triggered. Won't be used between loops!")]
protected float delay
Field Value
Type | Description |
---|---|
float | Delay before starting the animation once triggered. Won't be used between loops. |
duration
Declaration
[SerializeField]
[Tooltip("Duration of tween animation.")]
protected float duration
Field Value
Type | Description |
---|---|
float | Duration of tween animation. |
ease
Declaration
[SerializeField]
[HideIf("useCustomEase")]
[Tooltip("Ease of the animation.")]
protected Ease ease
Field Value
Type | Description |
---|---|
Ease | Ease of the animation. |
easeCurve
Declaration
[SerializeField]
[ShowIf("useCustomEase")]
[Tooltip("Curve followed to reach the final value. (e.g. Linear, Sine,...)")]
protected AnimationCurve easeCurve
Field Value
Type | Description |
---|---|
AnimationCurve | Curve followed to reach the final value. (e.g. Linear, Sine,...) |
enableTriggerWhileDisable
Declaration
[Header("Tween - Advanced")]
[SerializeField]
[Tooltip("A tween can be triggered if its method is called. Decide if it is permitted.")]
protected bool enableTriggerWhileDisable
Field Value
Type | Description |
---|---|
bool | A tween can be triggered if its method Trigger() is called. Decide if it is permitted. |
loopCount
Declaration
[Header("Tween - Behaviour")]
[SerializeField]
[Tooltip("Set '-1' for infinite loops")]
protected int loopCount
Field Value
Type | Description |
---|---|
int | Define how many time the animation will be repeated once triggered. |
Remarks
Set '-1' for infinite loops.
loopType
Declaration
[SerializeField]
[Tooltip("Define how the tween animation will loop.")]
protected LoopType loopType
Field Value
Type | Description |
---|---|
LoopType | Define how the tween animation will loop. |
onComplete
Declaration
[Foldout("Events")]
[SerializeField]
[Tooltip("This event is triggered when the tween is fully completed.")]
protected UnityEvent onComplete
Field Value
Type | Description |
---|---|
UnityEvent | This event is triggered when the tween is fully completed. |
onStart
Declaration
[Foldout("Events")]
[SerializeField]
[Tooltip("This event is triggered when the tween is started.")]
protected UnityEvent onStart
Field Value
Type | Description |
---|---|
UnityEvent | This event is triggered when the tween is started. |
onUpdate
Declaration
[Foldout("Events")]
[SerializeField]
[Tooltip("This event is triggered every frame while the tween is running.")]
protected UnityEvent onUpdate
Field Value
Type | Description |
---|---|
UnityEvent | This event is triggered every frame while the tween is running. |
randomizeStartPoint
Declaration
[SerializeField]
[Tooltip("Ignores the delay and set a random position on the curve, in range [0;1].")]
protected bool randomizeStartPoint
Field Value
Type | Description |
---|---|
bool | Ignores the delay and set a random position on the curve, in range [0;1]. |
resetOnDisable
Declaration
[SerializeField]
[Tooltip("Resets object base state when disabled/killed (not on completion).")]
protected bool resetOnDisable
Field Value
Type | Description |
---|---|
bool | Resets object base state when disabled/killed (not on completion) |
startTime
Declaration
protected float startTime
Field Value
Type | Description |
---|---|
float | Base class for anything you want to tween via inspector. |
syncToTweensStart
Declaration
[SerializeField]
[Tooltip("Ignores the delay and sync movement to the other similar tweens.\nYou really should have a 'restart' looptype when activating this.")]
protected bool syncToTweensStart
Field Value
Type | Description |
---|---|
bool | Ignores the delay and syncs movement to the other similar tweens. You really should set loopType to DG.Tweening.LoopType.Restart when activating this. |
target
Declaration
[Header("Tween - Settings")]
[SerializeField]
[Tooltip("Target to animate. If not set, it will find one in GameObject or children.")]
protected T target
Field Value
Type | Description |
---|---|
T | Target to animate. If not set, it will find one in GameObject or children. |
useCustomEase
Declaration
[SerializeField]
[Tooltip("Will use a custom curve instead of usual default curve.")]
protected bool useCustomEase
Field Value
Type | Description |
---|---|
bool | Will use a custom curve instead of usual default curve. |
Properties
| Edit this page View SourceOnComplete
This event is triggered when the tween is fully completed.
Declaration
public UnityEvent OnComplete { get; }
Property Value
Type | Description |
---|---|
UnityEvent | Base class for anything you want to tween via inspector. |
OnStart
This event is triggered when the tween is fully completed.
Declaration
public UnityEvent OnStart { get; }
Property Value
Type | Description |
---|---|
UnityEvent | Base class for anything you want to tween via inspector. |
OnUpdate
This event is triggered every frame while the tween is running.
Declaration
public UnityEvent OnUpdate { get; }
Property Value
Type | Description |
---|---|
UnityEvent | Base class for anything you want to tween via inspector. |
Target
Target to animate. If not set, it will find one in GameObject or children.
Declaration
public T Target { get; set; }
Property Value
Type | Description |
---|---|
T | Base class for anything you want to tween via inspector. |
Methods
| Edit this page View SourceGenerateTween()
Create the animation with DOTween.
Declaration
public abstract Tween GenerateTween()
Returns
Type | Description |
---|---|
Tween | Base class for anything you want to tween via inspector. |
Remarks
It can be generated by extension from the target type (check shortcuts) or with DG.Tweening.DOTween static methods.
If you need to add an OnStart/OnUpdate/OnCompleted event, please use the ones in Tween<T> class.
Kill()
Kill the tween animation
Declaration
public override void Kill()
Overrides
| Edit this page View SourceResetState()
Restore the values you buffered via SaveState(). Used when restoring on disable.
Declaration
public abstract void ResetState()
SaveState()
Buffer the values of the target concerned by the animation. Used when restoring on disable.
Declaration
public abstract void SaveState()
Trigger()
Trigger the tween animation
Declaration
public override void Trigger()