You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: Assets/Samples/GamepadMouseCursor/README.md
+5-4
Original file line number
Diff line number
Diff line change
@@ -7,10 +7,11 @@ This sample demonstrates how to set this up with the input system.
7
7
1) It uses a custom [actions file](./GamepadMouseCursorUIActions.inputactions) for feeding input to the UI as the default actions are set up for gamepad navigation – something we don't want here as it would conflict with gamepad input being used for virtual cursor navigation.
8
8
2) Note how `InputSystemUIInputModule` on the `EventSystem` GameObject is set up to reference actions from that file.
9
9
3) The key component to take a look at is `VirtualMouseInput` on `Canvas >> Cursor`. The component is set up to receive input from the gamepad and translates it into motion on the `RectTransform` it is given. When going into play mode, you should also see a `Virtual Mouse` being added to the devices by the component.
10
-
4) Note how the anchor position on the `RectTransform` is set to bottom left. This way the coordinate system responds to how mouse screen space operates.
11
-
5) Note how `Cursor` is the last child of `Canvas` so that it draws on top of everything else.
12
-
6) Note that `Raycast Target` on the `Image` component of the cursor is turned off to avoid raycasts from the mouse cursor hitting the cursor itself.
13
-
7) Note that `Cursor Mode` on the `VirtualMouseInput` component is set to `Hardware Cursor If Available`. This will cause the component to look for a system mouse. If present, the system mouse is disabled and the system mouse cursor is warped to the virtual mouse position using `Mouse.WarpCursorPosition`. If no system mouse is present, `Cursor Graphic` will be used as a software mouse cursor.
10
+
4) Note how `Cursor` is the last child of `Canvas` so that it draws on top of everything else.
11
+
5) Note that `Raycast Target` on the `Image` component of the cursor is turned off to avoid raycasts from the mouse cursor hitting the cursor itself.
12
+
6) Note that `Cursor Mode` on the `VirtualMouseInput` component is set to `Hardware Cursor If Available`. This will cause the component to look for a system mouse. If present, the system mouse is disabled and the system mouse cursor is warped to the virtual mouse position using `Mouse.WarpCursorPosition`. If no system mouse is present, `Cursor Graphic` will be used as a software mouse cursor.
13
+
14
+
>NOTE: The `VirtualMouseInput` component currently does not work correctly with world-space canvases.
Copy file name to clipboardexpand all lines: Packages/com.unity.inputsystem/CHANGELOG.md
+5
Original file line number
Diff line number
Diff line change
@@ -13,6 +13,11 @@ however, it has to be formatted properly to pass verification tests.
13
13
### Fixed
14
14
15
15
- Fixed unclosed profiler marker in `InvokeCallbacksSafe_AnyCallbackReturnsTrue` which would lead to eventually broken profiler traces in some cases like using `PlayerInput` (case ISXB-393).
16
+
-`VirtualMouseInput` not working correctly with `CanvasScaler` settings other than `ConstantPixelSize`. Fix contributed by [ad-walker](https://github.com/ad-walker) in [#1078](https://github.com/Unity-Technologies/InputSystem/pull/1078).
17
+
18
+
### Added
19
+
20
+
- Added an explicit `Disable System Mouse` setting to `VirtualMouseInput` to allow toggling the default behavior off which makes the component turn off the system mouse while it is enabled (so as to suppress the system mouse doubling the input activity on the VirtualMouse).
Copy file name to clipboardexpand all lines: Packages/com.unity.inputsystem/InputSystem/Plugins/UI/VirtualMouseInput.cs
+62-10
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@
5
5
6
6
////TODO: respect cursor lock mode
7
7
8
+
////TODO: find a way to automatically turn the gamepad cursor on/off based on gamepad use
9
+
8
10
////TODO: investigate how driving the HW cursor behaves when FPS drops low
9
11
//// (also, maybe we can add support where we turn the gamepad mouse on and off automatically based on whether the system mouse is used)
10
12
@@ -14,6 +16,8 @@
14
16
15
17
////TODO: make it work with PlayerInput such that it will automatically look up actions in the actual PlayerInput instance it is used with (based on the action IDs it has)
16
18
19
+
////FIXME: make this work with world-space canvases
20
+
17
21
////REVIEW: should we default the SW cursor position to the center of the screen?
18
22
19
23
////REVIEW: consider this for inclusion directly in the input system
@@ -78,9 +82,10 @@ public float cursorSpeed
78
82
/// that is made to correspond to the position of <see cref="virtualMouse"/>. If this is set to <see
79
83
/// cref="CursorMode.HardwareCursorIfAvailable"/> and there is a native <see cref="Mouse"/> device present,
80
84
/// the component will take over that mouse device and disable it (so as for it to not also generate position
81
-
/// updates). It will then use <see cref="Mouse.WarpCursorPosition"/> to move the system mouse cursor to
82
-
/// correspond to the position of the <see cref="virtualMouse"/>. In this case, <see cref="cursorGraphic"/>
83
-
/// will be disabled and <see cref="cursorTransform"/> will not be updated.
85
+
/// updates) except when this is explicitly disabled via <see cref="disableSystemMouse"/>. It will then use
86
+
/// <see cref="Mouse.WarpCursorPosition"/> to move the system mouse cursor to correspond to the position of the
87
+
/// <see cref="virtualMouse"/>. In this case, <see cref="cursorGraphic"/> will be disabled and
88
+
/// <see cref="cursorTransform"/> will not be updated.
84
89
/// </summary>
85
90
/// <value>Whether the system mouse cursor (if present) should be made to correspond with the virtual mouse position.</value>
86
91
/// <remarks>
@@ -100,7 +105,8 @@ public CursorMode cursorMode
100
105
// If we're turning it off, make sure we re-enable the system mouse.
0 commit comments