docs.unity3d.com
    Show / Hide Table of Contents

    Class TweenableVariableBase<T>

    Tweenable variable uses bindable variable and target value to tween over time towards a target value.

    Inheritance
    Object
    BindableVariableBase<T>
    BindableVariable<T>
    TweenableVariableBase<T>
    TweenableVariableAsyncBase<T>
    TweenableVariableSynchronousBase<T>
    Inherited Members
    BindableVariable<T>.ValueEquals(T)
    BindableVariableBase<T>.SetValueWithoutNotify(T)
    BindableVariableBase<T>.Subscribe(Action<T>)
    BindableVariableBase<T>.SubscribeAndUpdate(Action<T>)
    BindableVariableBase<T>.Unsubscribe(Action<T>)
    BindableVariableBase<T>.BroadcastValue()
    BindableVariableBase<T>.Task(Func<T, Boolean>, CancellationToken)
    BindableVariableBase<T>.Task(T, CancellationToken)
    BindableVariableBase<T>.Value
    BindableVariableBase<T>.BindingCount
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    Namespace: UnityEngine.XR.Interaction.Toolkit.Utilities.Tweenables
    Syntax
    public abstract class TweenableVariableBase<T> : BindableVariable<T>, IReadOnlyBindableVariable<T> where T : IEquatable<T>
    Type Parameters
    Name Description
    T

    BindableVariable type.

    Fields

    k_NearlyOne

    Threshold to compare tween amount above which the tween is short-circuited to the target value.

    Declaration
    protected const float k_NearlyOne = 0.99999F
    Field Value
    Type Description
    Single

    Properties

    animationCurve

    Animation curve used for sequence animations.

    Declaration
    public AnimationCurve animationCurve { get; set; }
    Property Value
    Type Description
    AnimationCurve

    initialValue

    Initial value used for certain tween jobs that need to process from the initial state.

    Declaration
    public T initialValue { get; set; }
    Property Value
    Type Description
    T

    target

    Target value used when tweening variable value.

    Declaration
    public T target { get; set; }
    Property Value
    Type Description
    T
    See Also
    Value

    Methods

    ExecuteTween(T, T, Single, Boolean)

    Tween from current value to target using tween target.

    Declaration
    protected abstract void ExecuteTween(T startValue, T targetValue, float tweenAmount, bool useCurve = false)
    Parameters
    Type Name Description
    T startValue

    Tween starting value.

    T targetValue

    Tween target value.

    Single tweenAmount

    Value between 0-1 used in tween evaluation.

    Boolean useCurve

    Whether the animation curve should be used in the tween evaluation.

    See Also
    HandleTween(Single)

    HandleTween(Single)

    Tween from current value to target using tween target.

    Declaration
    public void HandleTween(float tweenTarget)
    Parameters
    Type Name Description
    Single tweenTarget

    Value between 0-1 used in tween evaluation.

    OnAnimationCurveChanged(AnimationCurve)

    Called when the animation curve reference used for sequence animations changed.

    Declaration
    protected virtual void OnAnimationCurveChanged(AnimationCurve value)
    Parameters
    Type Name Description
    AnimationCurve value

    The new value of the property.

    See Also
    animationCurve

    OnTargetChanged(T)

    Callback when new tween target value is assigned.

    Declaration
    protected virtual void OnTargetChanged(T newTarget)
    Parameters
    Type Name Description
    T newTarget

    New target value.

    See Also
    target

    PlaySequence(T, T, Single, Action)

    Play sequence to animate value from start to finish over given duration.

    Declaration
    public IEnumerator PlaySequence(T start, T finish, float duration, Action onComplete = null)
    Parameters
    Type Name Description
    T start

    Value to start animation at.

    T finish

    Target Value to end animation at.

    Single duration

    Duration of animation.

    Action onComplete

    Optional callback when animation completes.

    Returns
    Type Description
    IEnumerator

    Returns enumerator used for coroutine.

    PreprocessTween()

    Logic to execute before a tween can be processed.

    Declaration
    protected virtual void PreprocessTween()

    StartAutoTween(Single)

    Coroutine used to automatically tween every frame.

    Declaration
    public IEnumerator StartAutoTween(float deltaTimeMultiplier)
    Parameters
    Type Name Description
    Single deltaTimeMultiplier

    Multiplier used to scale deltaTime for tweens.

    Returns
    Type Description
    IEnumerator

    Returns enumerator used for coroutine.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023