File tree Expand file tree Collapse file tree 4 files changed +16
-9
lines changed
MixedRealityToolkit-SDK/Features/UX/Scripts/Pointers
MixedRealityToolkit/_Core/Devices/UnityInput Expand file tree Collapse file tree 4 files changed +16
-9
lines changed Original file line number Diff line number Diff 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 {
Original file line number Diff line number Diff 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 &&
Original file line number Diff line number Diff 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" ) ;
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments