docs.unity.cn
    Show / Hide Table of Contents

    Struct InputAxis

    Defines an input axis. This is a field that can take on any value in a range, with optional wrapping to form a loop.

    Namespace: Unity.Cinemachine
    Syntax
    [Serializable]
    public struct InputAxis

    Fields

    Center

    The centered, or at-rest value of this axis.

    Declaration
    [Tooltip("The centered, or at-rest value of this axis.")]
    public float Center
    Field Value
    Type Description
    Single

    Range

    The valid range for the axis value. Value will be clamped to this range.

    Declaration
    [Tooltip("The valid range for the axis value.  Value will be clamped to this range.")]
    public Vector2 Range
    Field Value
    Type Description
    Vector2

    Recentering

    Controls automatic re-centering of axis

    Declaration
    [FoldoutWithEnabledButton("Enabled")]
    public InputAxis.RecenteringSettings Recentering
    Field Value
    Type Description
    InputAxis.RecenteringSettings

    Restrictions

    Some usages require restricted functionality. This is set here.

    Declaration
    [HideInInspector]
    public InputAxis.RestrictionFlags Restrictions
    Field Value
    Type Description
    InputAxis.RestrictionFlags

    Value

    The current value of the axis. You can drive this directly from a script

    Declaration
    [Tooltip("The current value of the axis.  You can drive this directly from a script.")]
    public float Value
    Field Value
    Type Description
    Single

    Wrap

    If set, then the axis will wrap around at the min/max values, forming a loop

    Declaration
    [Tooltip("If set, then the axis will wrap around at the min/max values, forming a loop")]
    public bool Wrap
    Field Value
    Type Description
    Boolean

    Properties

    DefaultMomentary

    An InputAxis set up as a normalized momentary control ranging from -1...1 with Center = 0

    Declaration
    public static readonly InputAxis DefaultMomentary { get; }
    Property Value
    Type Description
    InputAxis

    Methods

    CancelRecentering()

    Cancel any current re-centering in progress, and reset the wait time

    Declaration
    public void CancelRecentering()

    ClampValue(Single)

    Clamp the value to range, taking wrap into account

    Declaration
    public float ClampValue(float v)
    Parameters
    Type Name Description
    Single v

    The value to clamp

    Returns
    Type Description
    Single

    The value clamped to the axis range

    DoRecentering(Single, Boolean)

    Call this to manage re-centering axis value to axis center. This assumes that TrackValueChange() has been called already this frame.

    Declaration
    public void DoRecentering(float deltaTime, bool forceCancel)
    Parameters
    Type Name Description
    Single deltaTime

    Current deltaTime, or -1 for immediate re-centering

    Boolean forceCancel

    If true, cancel any re-centering currently in progress and reset the timer.

    GetClampedValue()

    Get the clamped axis value

    Declaration
    public float GetClampedValue()
    Returns
    Type Description
    Single

    The axis value, clamped to the axis range

    GetNormalizedValue()

    Clamp and scale the value to range 0...1, taking wrap into account

    Declaration
    public float GetNormalizedValue()
    Returns
    Type Description
    Single

    The axis value, mapped onto [0...1]

    RecenterNow()

    Trigger re-centering immediately, regardless of whether re-centering is enabled or the wait time has elapsed.

    Declaration
    public void RecenterNow()

    Reset()

    Reset axis to at-rest state

    Declaration
    public void Reset()

    TrackValueChange()

    Call this before calling DoRecentering. Will track any value changes so that the re-centering clock is updated properly.

    Declaration
    public bool TrackValueChange()
    Returns
    Type Description
    Boolean

    True if value changed. This value can be used to cancel re-centering when multiple input axes are coupled.

    Validate()

    Make sure the settings are well-formed

    Declaration
    public void Validate()
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Saturday, May 6, 2023