Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions Assets/Samples/GamepadMouseCursor/GamepadMouseCursorSample.unity
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ OcclusionCullingSettings:
--- !u!104 &2
RenderSettings:
m_ObjectHideFlags: 0
serializedVersion: 9
serializedVersion: 10
m_Fog: 0
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
m_FogMode: 3
Expand Down Expand Up @@ -42,8 +42,8 @@ RenderSettings:
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
serializedVersion: 13
m_BakeOnSceneLoad: 0
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
Expand All @@ -66,9 +66,6 @@ LightmapSettings:
m_LightmapParameters: {fileID: 0}
m_LightmapsBakeMode: 1
m_TextureCompression: 1
m_FinalGather: 0
m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_MixedBakeMode: 2
m_BakeBackend: 1
Expand Down Expand Up @@ -977,10 +974,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ReferenceResolution: {x: 1920, y: 1080}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
Expand Down Expand Up @@ -1100,15 +1097,14 @@ Light:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 832288260}
m_Enabled: 1
serializedVersion: 10
serializedVersion: 12
m_Type: 1
m_Shape: 0
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
m_InnerSpotAngle: 21.80208
m_CookieSize: 10
m_CookieSize2D: {x: 10, y: 10}
m_Shadows:
m_Type: 2
m_Resolution: -1
Expand Down Expand Up @@ -1152,8 +1148,12 @@ Light:
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
m_UseBoundingSphereOverride: 0
m_UseViewFrustumForShadowCasterCull: 1
m_ForceVisible: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
m_LightUnit: 1
m_LuxAtDistance: 1
m_EnableSpotReflector: 1
--- !u!4 &832288262
Transform:
m_ObjectHideFlags: 0
Expand Down
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ however, it has to be formatted properly to pass verification tests.
- Fixed warnings being generated on Unity 6.4 and 6.5. (ISX-2395).
- Fixed extra empty lines being displayed in the control binding list when mouse buttons are pressed [ISXB-1677](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1677)
- Fixed InputActionReference not being set when attempting to set it on a Prefab or ScriptableObject [ISXB-1787](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1787)
- Fixed misaligned Virtual Cursor when changing resolution [ISXB-1119](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1119)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the missing CHANGELOG entry.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Darren-Kelly-Unity changelog is under the wrong area, should be under unreleased


## [1.17.0] - 2025-11-25

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

////TODO: add support for acceleration

////TODO: automatically scale mouse speed to resolution such that it stays constant regardless of resolution

////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)

////REVIEW: should we default the SW cursor position to the center of the screen?
Expand Down Expand Up @@ -291,7 +289,10 @@

// Add mouse device.
if (m_VirtualMouse == null)
{
m_VirtualMouse = (Mouse)InputSystem.AddDevice("VirtualMouse");
TryFindCanvas();
}
else if (!m_VirtualMouse.added)
InputSystem.AddDevice(m_VirtualMouse);

Expand Down Expand Up @@ -370,6 +371,7 @@
private void TryFindCanvas()
{
m_Canvas = m_CursorGraphic?.GetComponentInParent<Canvas>();
m_CanvasScaler = m_CursorGraphic?.GetComponentInParent<CanvasScaler>();
}

private void TryEnableHardwareCursor()
Expand Down Expand Up @@ -421,6 +423,14 @@
}
else
{
var resolutionXScale = 1f;
var resolutionYScale = 1f;
if (m_CanvasScaler != null)
{
resolutionXScale = m_Canvas.pixelRect.xMax / m_CanvasScaler.referenceResolution.x;
resolutionYScale = m_Canvas.pixelRect.yMax / m_CanvasScaler.referenceResolution.y;
}

Check warning on line 432 in Packages/com.unity.inputsystem/InputSystem/Plugins/UI/VirtualMouseInput.cs

View check run for this annotation

Codecov GitHub.com / codecov/patch

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/VirtualMouseInput.cs#L429-L432

Added lines #L429 - L432 were not covered by tests

var currentTime = InputState.currentTime;
if (Mathf.Approximately(0, m_LastStickValue.x) && Mathf.Approximately(0, m_LastStickValue.y))
{
Expand All @@ -430,7 +440,7 @@

// Compute delta.
var deltaTime = (float)(currentTime - m_LastTime);
var delta = new Vector2(m_CursorSpeed * stickValue.x * deltaTime, m_CursorSpeed * stickValue.y * deltaTime);
var delta = new Vector2(m_CursorSpeed * resolutionXScale * stickValue.x * deltaTime, m_CursorSpeed * resolutionYScale * stickValue.y * deltaTime);

// Update position.
var currentPosition = m_VirtualMouse.position.value;
Expand All @@ -454,7 +464,9 @@
if (m_CursorTransform != null &&
(m_CursorMode == CursorMode.SoftwareCursor ||
(m_CursorMode == CursorMode.HardwareCursorIfAvailable && m_SystemMouse == null)))
m_CursorTransform.anchoredPosition = newPosition;
{
m_CursorTransform.anchoredPosition = m_CanvasScaler == null ? newPosition : new Vector2(newPosition.x / resolutionXScale, newPosition.y / resolutionYScale);
}

m_LastStickValue = stickValue;
m_LastTime = currentTime;
Expand Down Expand Up @@ -508,6 +520,7 @@
[SerializeField] private InputActionProperty m_ScrollWheelAction;

private Canvas m_Canvas; // Canvas that gives the motion range for the software cursor.
private CanvasScaler m_CanvasScaler;
private Mouse m_VirtualMouse;
private Mouse m_SystemMouse;
private Action m_AfterInputUpdateDelegate;
Expand Down