docs.unity.cn

Input System 1.6.1

    Show / Hide Table of Contents

    Class ButtonControl

    An axis that has a trigger point beyond which it is considered to be pressed.

    Inheritance
    Object
    InputControl
    InputControl<Single>
    AxisControl
    ButtonControl
    AnyKeyControl
    DiscreteButtonControl
    KeyControl
    TouchPressControl
    Inherited Members
    AxisControl.clamp
    AxisControl.clampMin
    AxisControl.clampMax
    AxisControl.clampConstant
    AxisControl.invert
    AxisControl.normalize
    AxisControl.normalizeMin
    AxisControl.normalizeMax
    AxisControl.normalizeZero
    AxisControl.scale
    AxisControl.scaleFactor
    AxisControl.Preprocess(Single)
    AxisControl.FinishSetup()
    AxisControl.ReadUnprocessedValueFromState(Void*)
    AxisControl.WriteValueIntoState(Single, Void*)
    AxisControl.CompareValue(Void*, Void*)
    AxisControl.EvaluateMagnitude(Void*)
    AxisControl.CalculateOptimizedControlDataType()
    InputControl<Single>.valueType
    InputControl<Single>.valueSizeInBytes
    InputControl<Single>.value
    InputControl<Single>.ReadValue()
    InputControl<Single>.ReadValueFromPreviousFrame()
    InputControl<Single>.ReadDefaultValue()
    InputControl<Single>.ReadValueFromState(Void*)
    InputControl<Single>.ReadValueFromStateWithCaching(Void*)
    InputControl<Single>.ReadUnprocessedValueFromStateWithCaching(Void*)
    InputControl<Single>.ReadUnprocessedValue()
    InputControl<Single>.ReadValueFromStateAsObject(Void*)
    InputControl<Single>.ReadValueFromStateIntoBuffer(Void*, Void*, Int32)
    InputControl<Single>.WriteValueFromBufferIntoState(Void*, Int32, Void*)
    InputControl<Single>.WriteValueFromObjectIntoState(Object, Void*)
    InputControl<Single>.ReadValueFromBufferAsObject(Void*, Int32)
    InputControl<Single>.ProcessValue(Single)
    InputControl<Single>.ProcessValue(Single)
    InputControl.name
    InputControl.displayName
    InputControl.shortDisplayName
    InputControl.path
    InputControl.layout
    InputControl.variants
    InputControl.device
    InputControl.parent
    InputControl.children
    InputControl.usages
    InputControl.aliases
    InputControl.stateBlock
    InputControl.noisy
    InputControl.synthetic
    InputControl.Item[String]
    InputControl.magnitude
    InputControl.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.TryGetChildControl(String)
    InputControl.TryGetChildControl<TControl>(String)
    InputControl.GetChildControl(String)
    InputControl.GetChildControl<TControl>(String)
    InputControl.RefreshConfigurationIfNeeded()
    InputControl.RefreshConfiguration()
    InputControl.m_StateBlock
    InputControl.currentStatePtr
    InputControl.previousFrameStatePtr
    InputControl.defaultStatePtr
    InputControl.noiseMaskPtr
    InputControl.stateOffsetRelativeToDeviceRoot
    InputControl.optimizedControlDataType
    InputControl.ApplyParameterChanges()
    Namespace: UnityEngine.InputSystem.Controls
    Syntax
    public class ButtonControl : AxisControl
    Remarks

    By default stored as a single bit. In that format, buttons will only yield 0 and 1 as values. However, buttons return are AxisControls and yield full floating-point values and may thus have a range of values. See pressPoint for how button presses on such buttons are handled.

    Constructors

    ButtonControl()

    Default-initialize the control.

    Declaration
    public ButtonControl()
    Remarks

    The default format for the control is FormatBit. The control's minimum value is set to 0 and the maximum value to 1.

    Fields

    pressPoint

    The minimum value the button has to reach for it to be considered pressed.

    Declaration
    public float pressPoint
    Field Value
    Type Description
    Single

    Button press threshold.

    Remarks

    The button is considered pressed, if it has a value equal to or greater than this value.

    By default, this property is set to -1. If the value of the property is negative, defaultButtonPressPoint is used.

    The value can be configured as a parameter in a layout.

    public class MyDevice : InputDevice
    {
        [InputControl(parameters = "pressPoint=0.234")]
        public ButtonControl button { get; private set; }
    
        //...
    }
    See Also
    defaultButtonPressPoint
    pressPointOrDefault
    isPressed

    Properties

    isPressed

    Whether the button is currently pressed.

    Declaration
    public bool isPressed { get; }
    Property Value
    Type Description
    Boolean

    True if button is currently pressed.

    Remarks

    A button is considered press if it's value is equal to or greater than its button press threshold (pressPointOrDefault).

    See Also
    defaultButtonPressPoint
    pressPoint
    onAnyButtonPress

    pressPointOrDefault

    Return pressPoint if set, otherwise return defaultButtonPressPoint.

    Declaration
    public float pressPointOrDefault { get; }
    Property Value
    Type Description
    Single

    Effective value to use for press point thresholds.

    See Also
    defaultButtonPressPoint

    wasPressedThisFrame

    Whether the press started this frame.

    Declaration
    public bool wasPressedThisFrame { get; }
    Property Value
    Type Description
    Boolean

    True if the current press of the button started this frame.

    Remarks
    // An example showing the use of this property on a gamepad button and a keyboard key.
    
    using UnityEngine;
    using UnityEngine.InputSystem;
    
    public class ExampleScript : MonoBehaviour
    {
        void Update()
        {
            bool buttonPressed = Gamepad.current.aButton.wasPressedThisFrame;
            bool spaceKeyPressed = Keyboard.current.spaceKey.wasPressedThisFrame;
        }
    }

    wasReleasedThisFrame

    Declaration
    public bool wasReleasedThisFrame { get; }
    Property Value
    Type Description
    Boolean

    Methods

    IsValueConsideredPressed(Single)

    Whether the given value would be considered pressed for this button.

    Declaration
    public bool IsValueConsideredPressed(float value)
    Parameters
    Type Name Description
    Single value

    Value for the button.

    Returns
    Type Description
    Boolean

    True if value crosses the threshold to be considered pressed.

    See Also
    pressPoint
    defaultButtonPressPoint

    Extension Methods

    InputControlExtensions.FindInParentChain<TControl>(InputControl)
    InputControlExtensions.IsPressed(InputControl, Single)
    InputControlExtensions.IsActuated(InputControl, Single)
    InputControlExtensions.ReadValueAsObject(InputControl)
    InputControlExtensions.ReadValueIntoBuffer(InputControl, Void*, Int32)
    InputControlExtensions.ReadDefaultValueAsObject(InputControl)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.ReadValueFromEventAsObject(InputControl, InputEventPtr)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.WriteValueFromObjectIntoEvent(InputControl, InputEventPtr, Object)
    InputControlExtensions.WriteValueIntoState(InputControl, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl, TValue, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, TValue, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, Void*)
    InputControlExtensions.WriteValueIntoState<TValue, TState>(InputControl<TValue>, TValue, ref TState)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl, TValue, InputEventPtr)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl<TValue>, TValue, InputEventPtr)
    InputControlExtensions.CheckStateIsAtDefault(InputControl)
    InputControlExtensions.CheckStateIsAtDefault(InputControl, Void*, Void*)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl, Void*)
    InputControlExtensions.CompareStateIgnoringNoise(InputControl, Void*)
    InputControlExtensions.CompareState(InputControl, Void*, Void*, Void*)
    InputControlExtensions.CompareState(InputControl, Void*, Void*)
    InputControlExtensions.HasValueChangeInState(InputControl, Void*)
    InputControlExtensions.HasValueChangeInEvent(InputControl, InputEventPtr)
    InputControlExtensions.GetStatePtrFromStateEvent(InputControl, InputEventPtr)
    InputControlExtensions.ResetToDefaultStateInEvent(InputControl, InputEventPtr)
    InputControlExtensions.QueueValueChange<TValue>(InputControl<TValue>, TValue, Double)
    InputControlExtensions.AccumulateValueInEvent(InputControl<Single>, Void*, InputEventPtr)
    InputControlExtensions.FindControlsRecursive<TControl>(InputControl, IList<TControl>, Func<TControl, Boolean>)
    In This Article
    • Constructors
      • ButtonControl()
    • Fields
      • pressPoint
    • Properties
      • isPressed
      • pressPointOrDefault
      • wasPressedThisFrame
      • wasReleasedThisFrame
    • Methods
      • IsValueConsideredPressed(Single)
    • Extension Methods
    Back to top Copyright © 2023 Unity Technologies — Terms of use
    Generated by DocFX
    on Saturday, May 27, 2023