Skip to content

Commit 1365a7a

Browse files
author
Julia Schwarz
committed
Unity UI support HoloLens 1 hands by adding case when the pointer ray is decoupled from the pointer, as in hands case.
1 parent 7ee45fc commit 1365a7a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Assets/MixedRealityToolkit.Services/InputSystem/MixedRealityInputModule.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,22 @@ protected MouseState GetMousePointerEventDataForMrtkPointer(PointerData pointerD
191191

192192
// Reset the RaycastCamera for projecting (used in calculating deltas)
193193
Debug.Assert(pointer.Rays != null && pointer.Rays.Length > 0);
194-
RaycastCamera.transform.position = pointer.Rays[0].Origin;
195-
RaycastCamera.transform.rotation = Quaternion.LookRotation(pointer.Rays[0].Direction);
194+
195+
if (pointer.Controller != null && pointer.Controller.IsRotationAvailable)
196+
{
197+
RaycastCamera.transform.position = pointer.Rays[0].Origin;
198+
RaycastCamera.transform.rotation = Quaternion.LookRotation(pointer.Rays[0].Direction);
199+
}
200+
else
201+
{
202+
// The pointer.Controller does not provide rotation, for example on HoloLens 1 hands.
203+
// In this case pointer.Rays[0].Origin will be the head position, but we want the
204+
// hand to do drag operations, not the head.
205+
// pointer.Position gives the position of the hand, use that to compute drag deltas.
206+
RaycastCamera.transform.position = pointer.Position;
207+
RaycastCamera.transform.rotation = Quaternion.LookRotation(pointer.Rays[0].Direction);
208+
}
209+
196210

197211
// Populate eventDataLeft
198212
pointerData.eventDataLeft.Reset();

0 commit comments

Comments
 (0)