Search Results for

    Show / Hide Table of Contents

    Class Tween<T>

    Base class for anything you want to tween via inspector.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    TriggerBehaviour
    Tween<T>
    AlphaTween
    ColorTween
    GravitateTween
    MoveByTween
    RotateByTween
    RotateToTween
    ScaleTween
    Implements
    ITriggerState
    Inherited Members
    TriggerBehaviour.triggerOnceEnabled
    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 Source

    delay

    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.

    | Edit this page View Source

    duration

    Declaration
    [SerializeField]
    [Tooltip("Duration of tween animation.")]
    protected float duration
    Field Value
    Type Description
    float

    Duration of tween animation.

    | Edit this page View Source

    ease

    Declaration
    [SerializeField]
    [HideIf("useCustomEase")]
    [Tooltip("Ease of the animation.")]
    protected Ease ease
    Field Value
    Type Description
    Ease

    Ease of the animation.

    | Edit this page View Source

    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,...)

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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].

    | Edit this page View Source

    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)

    | Edit this page View Source

    startTime

    Declaration
    protected float startTime
    Field Value
    Type Description
    float Base class for anything you want to tween via inspector.
    | Edit this page View Source

    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.

    | Edit this page View Source

    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.

    | Edit this page View Source

    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 Source

    OnComplete

    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.
    | Edit this page View Source

    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.
    | Edit this page View Source

    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.
    | Edit this page View Source

    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 Source

    GenerateTween()

    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.

    | Edit this page View Source

    Kill()

    Kill the tween animation

    Declaration
    public override void Kill()
    Overrides
    TriggerBehaviour.Kill()
    | Edit this page View Source

    ResetState()

    Restore the values you buffered via SaveState(). Used when restoring on disable.

    Declaration
    public abstract void ResetState()
    | Edit this page View Source

    SaveState()

    Buffer the values of the target concerned by the animation. Used when restoring on disable.

    Declaration
    public abstract void SaveState()
    | Edit this page View Source

    Trigger()

    Trigger the tween animation

    Declaration
    public override void Trigger()
    Overrides
    TriggerBehaviour.Trigger()

    Implements

    ITriggerState
    • Edit this page
    • View Source
    In this article
    Back to top Generated by DocFX