Skip to content

Commit 8ed60df

Browse files
Fixed a few things with the mouse pointer.
Added notification when mouse device manager is started about how to regain mouse control.
1 parent 606f336 commit 8ed60df

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

Assets/MixedRealityToolkit-SDK/Features/UX/Scripts/Pointers/BaseControllerPointer.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,8 @@ protected override async void Start()
147147
TeleportSystem.Register(gameObject);
148148
}
149149

150-
if (InputSystem == null)
151-
{
152-
await WaitUntilInputSystemValid;
153-
SetCursor();
154-
}
150+
await WaitUntilInputSystemValid;
151+
SetCursor();
155152
}
156153

157154
protected override void OnDisable()
@@ -316,10 +313,14 @@ public virtual bool TryGetPointingRay(out Ray pointingRay)
316313
{
317314
Vector3 pointerPosition;
318315
TryGetPointerPosition(out pointerPosition);
319-
pointingRay = new Ray(pointerPosition, PointerDirection);
316+
pointingRay = pointerRay;
317+
pointingRay.origin = pointerPosition;
318+
pointingRay.direction = PointerDirection;
320319
return true;
321320
}
322321

322+
private readonly Ray pointerRay = new Ray();
323+
323324
/// <inheritdoc />
324325
public virtual bool TryGetPointerRotation(out Quaternion rotation)
325326
{

Assets/MixedRealityToolkit-SDK/Features/UX/Scripts/Pointers/MousePointer.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public override void OnSourcePoseChanged(SourcePoseEventData<Vector2> eventData)
7777
/// <inheritdoc />
7878
public override void OnPositionInputChanged(InputEventData<Vector2> eventData)
7979
{
80-
8180
if (eventData.SourceId == Controller?.InputSource.SourceId)
8281
{
8382
if (!UseSourcePoseData &&

Assets/MixedRealityToolkit/_Core/Devices/UnityInput/MouseController.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,11 @@ public void Update()
6666
return;
6767
}
6868

69-
controllerPose.Position = InputSource.Pointers[0].BaseCursor.Position;
70-
controllerPose.Rotation = InputSource.Pointers[0].BaseCursor.Rotation;
69+
if (InputSource.Pointers[0].BaseCursor != null)
70+
{
71+
controllerPose.Position = InputSource.Pointers[0].BaseCursor.Position;
72+
controllerPose.Rotation = InputSource.Pointers[0].BaseCursor.Rotation;
73+
}
7174

7275
// Don't ask me why it's mapped weird. Bc Unity...
7376
mouseDelta.x = Input.GetAxis("Mouse X");

Assets/MixedRealityToolkit/_Core/Devices/UnityInput/MouseDeviceManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public override void Enable()
2828
return;
2929
}
3030

31+
#if UNITY_EDITOR
32+
UnityEditor.EditorWindow.focusedWindow.ShowNotification(new GUIContent("Press \"ESC\" to regain mouse control"));
33+
#endif
34+
3135
Cursor.visible = false;
3236
Cursor.lockState = CursorLockMode.Locked;
3337

0 commit comments

Comments
 (0)