Skip to content

Commit 7bf7107

Browse files
authored
Merge pull request #2833 from StephenHodgson/vNEXT-MouseNotifications
Mouse Pointer Updates
2 parents 4449c3c + beca44e commit 7bf7107

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
@@ -144,11 +144,8 @@ protected override async void Start()
144144
MixedRealityManager.TeleportSystem.Register(gameObject);
145145
}
146146

147-
if (MixedRealityManager.InputSystem == null)
148-
{
149-
await WaitUntilInputSystemValid;
150-
SetCursor();
151-
}
147+
await WaitUntilInputSystemValid;
148+
SetCursor();
152149
}
153150

154151
protected override void OnDisable()
@@ -311,10 +308,14 @@ public virtual bool TryGetPointingRay(out Ray pointingRay)
311308
{
312309
Vector3 pointerPosition;
313310
TryGetPointerPosition(out pointerPosition);
314-
pointingRay = new Ray(pointerPosition, PointerDirection);
311+
pointingRay = pointerRay;
312+
pointingRay.origin = pointerPosition;
313+
pointingRay.direction = PointerDirection;
315314
return true;
316315
}
317316

317+
private readonly Ray pointerRay = new Ray();
318+
318319
/// <inheritdoc />
319320
public virtual bool TryGetPointerRotation(out Quaternion rotation)
320321
{

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

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

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

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

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

7376
// Don't ask me why it's mapped weird. Bc Unity...
7477
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
@@ -29,6 +29,10 @@ public override void Enable()
2929
return;
3030
}
3131

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

0 commit comments

Comments
 (0)