docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class InputHelpers

    Helper class for different kinds of input.

    Inheritance
    object
    InputHelpers
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.Interaction.Toolkit
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    [MovedFrom("")]
    public static class InputHelpers

    Methods

    IsPressed(InputDevice, Button, out bool, float)

    Checks whether button is pressed or not.

    Declaration
    public static bool IsPressed(this InputDevice device, InputHelpers.Button button, out bool isPressed, float pressThreshold = -1)
    Parameters
    Type Name Description
    InputDevice device

    The input device.

    InputHelpers.Button button

    The button that is being checked.

    bool isPressed

    A boolean that will be true if button is pressed and false if not.

    float pressThreshold

    The threshold of what defines a press.

    Returns
    Type Description
    bool

    Returns true if device and button are valid. Otherwise, returns false.

    TryReadAxis2DValue(InputDevice, Axis2D, out Vector2)

    Tries to read and return the supplied 2D axis value.

    Declaration
    public static bool TryReadAxis2DValue(this InputDevice device, InputHelpers.Axis2D axis2D, out Vector2 value)
    Parameters
    Type Name Description
    InputDevice device

    The input device.

    InputHelpers.Axis2D axis2D

    The 2D axis to read the value.

    Vector2 value

    The 2D axis value; it will have the default Vector2 value if the 2D axis value can't be read.

    Returns
    Type Description
    bool

    Returns true if the 2D axis value can be read. Otherwise, returns false.

    TryReadSingleValue(InputDevice, Button, out float)

    Tries to read and return the supplied button value.

    Declaration
    public static bool TryReadSingleValue(this InputDevice device, InputHelpers.Button button, out float singleValue)
    Parameters
    Type Name Description
    InputDevice device

    The input device.

    InputHelpers.Button button

    The button to read the value.

    float singleValue

    The button value; it will have the default float value (0f) if the button value can't be read.

    Returns
    Type Description
    bool

    Returns true if the button value can be read. Otherwise, returns false.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)