docs.unity.cn

Input System 1.1.1

    Show / Hide Table of Contents

    Class Mouse

    An input device representing a mouse.

    Inheritance
    Object
    InputControl
    InputDevice
    Pointer
    Mouse
    Inherited Members
    Pointer.position
    Pointer.delta
    Pointer.radius
    Pointer.pressure
    Pointer.press
    Pointer.IInputStateCallbackReceiver.GetStateOffsetForEvent(InputControl, InputEventPtr, UInt32)
    InputDevice.InvalidDeviceId
    InputDevice.description
    InputDevice.enabled
    InputDevice.canRunInBackground
    InputDevice.added
    InputDevice.remote
    InputDevice.native
    InputDevice.updateBeforeRender
    InputDevice.deviceId
    InputDevice.lastUpdateTime
    InputDevice.wasUpdatedThisFrame
    InputDevice.allControls
    InputDevice.valueType
    InputDevice.valueSizeInBytes
    InputDevice.all
    InputDevice.ReadValueFromBufferAsObject(Void*, Int32)
    InputDevice.ReadValueFromStateAsObject(Void*)
    InputDevice.ReadValueFromStateIntoBuffer(Void*, Void*, Int32)
    InputDevice.CompareValue(Void*, Void*)
    InputDevice.OnConfigurationChanged()
    InputDevice.ExecuteCommand<TCommand>(TCommand)
    InputDevice.ExecuteCommand(InputDeviceCommand*)
    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.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.EvaluateMagnitude(Void*)
    InputControl.WriteValueFromBufferIntoState(Void*, Int32, Void*)
    InputControl.WriteValueFromObjectIntoState(Object, Void*)
    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
    Namespace: UnityEngine.InputSystem
    Syntax
    public class Mouse : Pointer, IInputStateCallbackReceiver
    Remarks

    Adds a scroll wheel and a typical 3-button setup with a left, middle, and right button.

    To control cursor display and behavior, use .

    Properties

    backButton

    The first side button, often labeled/used as "back".

    Declaration
    public ButtonControl backButton { get; protected set; }
    Property Value
    Type Description
    ButtonControl

    Control representing the back button on the mouse.

    Remarks

    On Windows, this corresponds to RI_MOUSE_BUTTON_4.

    clickCount

    Number of times any of the mouse buttons has been clicked in succession within the system-defined click time threshold.

    Declaration
    public IntegerControl clickCount { get; protected set; }
    Property Value
    Type Description
    IntegerControl

    Control representing the mouse click count.

    current

    The mouse that was added or updated last or null if there is no mouse connected to the system.

    Declaration
    public static Mouse current { get; }
    Property Value
    Type Description
    Mouse
    See Also
    MakeCurrent()

    forwardButton

    The second side button, often labeled/used as "forward".

    Declaration
    public ButtonControl forwardButton { get; protected set; }
    Property Value
    Type Description
    ButtonControl

    Control representing the forward button on the mouse.

    Remarks

    On Windows, this corresponds to RI_MOUSE_BUTTON_5.

    leftButton

    The left mouse button.

    Declaration
    public ButtonControl leftButton { get; protected set; }
    Property Value
    Type Description
    ButtonControl

    Control representing the left mouse button.

    middleButton

    The middle mouse button.

    Declaration
    public ButtonControl middleButton { get; protected set; }
    Property Value
    Type Description
    ButtonControl

    Control representing the middle mouse button.

    rightButton

    The right mouse button.

    Declaration
    public ButtonControl rightButton { get; protected set; }
    Property Value
    Type Description
    ButtonControl

    Control representing the right mouse button.

    scroll

    The horizontal and vertical scroll wheels.

    Declaration
    public Vector2Control scroll { get; protected set; }
    Property Value
    Type Description
    Vector2Control

    Control representing the mouse scroll wheels.

    Remarks

    The x component corresponds to the horizontal scroll wheel, the y component to the vertical scroll wheel. Most mice do not have horizontal scroll wheels and will thus only see activity on y.

    Methods

    FinishSetup()

    Perform final initialization tasks after the control hierarchy has been put into place.

    Declaration
    protected override void FinishSetup()
    Overrides
    Pointer.FinishSetup()
    Remarks

    This method can be overridden to perform control- or device-specific setup work. The most common use case is for looking up child controls and storing them in local getters.

    public class MyDevice : InputDevice
    {
        public ButtonControl button { get; private set; }
        public AxisControl axis { get; private set; }
    
        protected override void OnFinishSetup()
        {
            // Cache controls in getters.
            button = GetChildControl("button");
            axis = GetChildControl("axis");
        }
    }

    MakeCurrent()

    Called when the mouse becomes the current mouse.

    Declaration
    public override void MakeCurrent()
    Overrides
    Pointer.MakeCurrent()

    OnAdded()

    Called when the mouse is added to the system.

    Declaration
    protected override void OnAdded()
    Overrides
    InputDevice.OnAdded()

    OnNextUpdate()

    Implements OnNextUpdate() for the mouse.

    Declaration
    protected void OnNextUpdate()

    OnRemoved()

    Called when the device is removed from the system.

    Declaration
    protected override void OnRemoved()
    Overrides
    Pointer.OnRemoved()

    OnStateEvent(InputEventPtr)

    Implements OnStateEvent(InputEventPtr) for the mouse.

    Declaration
    protected void OnStateEvent(InputEventPtr eventPtr)
    Parameters
    Type Name Description
    InputEventPtr eventPtr

    WarpCursorPosition(Vector2)

    Move the operating system's mouse cursor.

    Declaration
    public void WarpCursorPosition(Vector2 position)
    Parameters
    Type Name Description
    Vector2 position

    New position in player window space.

    Remarks

    The position property will not update immediately but rather will update in the next input update.

    Explicit Interface Implementations

    IInputStateCallbackReceiver.OnNextUpdate()

    Declaration
    void IInputStateCallbackReceiver.OnNextUpdate()
    Implements
    IInputStateCallbackReceiver.OnNextUpdate()

    IInputStateCallbackReceiver.OnStateEvent(InputEventPtr)

    Declaration
    void IInputStateCallbackReceiver.OnStateEvent(InputEventPtr eventPtr)
    Parameters
    Type Name Description
    InputEventPtr eventPtr
    Implements
    IInputStateCallbackReceiver.OnStateEvent(InputEventPtr)

    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.ReadValueFromEventAsObject(InputControl, InputEventPtr)
    InputControlExtensions.WriteValueFromObjectIntoEvent(InputControl, InputEventPtr, Object)
    InputControlExtensions.WriteValueIntoState(InputControl, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl, TValue, Void*)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl, TValue, InputEventPtr)
    InputControlExtensions.CopyState(InputDevice, Void*, Int32)
    InputControlExtensions.CopyState<TState>(InputDevice, out TState)
    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.FindControlsRecursive<TControl>(InputControl, IList<TControl>, Func<TControl, Boolean>)
    In This Article
    • Properties
      • backButton
      • clickCount
      • current
      • forwardButton
      • leftButton
      • middleButton
      • rightButton
      • scroll
    • Methods
      • FinishSetup()
      • MakeCurrent()
      • OnAdded()
      • OnNextUpdate()
      • OnRemoved()
      • OnStateEvent(InputEventPtr)
      • WarpCursorPosition(Vector2)
    • Explicit Interface Implementations
      • IInputStateCallbackReceiver.OnNextUpdate()
      • IInputStateCallbackReceiver.OnStateEvent(InputEventPtr)
    • Extension Methods
    Back to top Copyright © 2020 Unity Technologies
    Generated by DocFX
    on Thursday, September 9, 2021