@@ -255,6 +255,12 @@ public void Set(MixedRealityRaycastHit hit, RayStep ray, int rayStepIndex, float
255255 public void Set ( RaycastResult result , Vector3 hitPointOnObject , Vector4 hitNormalOnObject , RayStep ray , int rayStepIndex , float rayDistance )
256256 {
257257 raycastHit = default ( MixedRealityRaycastHit ) ;
258+ raycastHit . point = hitPointOnObject ;
259+ raycastHit . normal = hitNormalOnObject ;
260+ raycastHit . distance = rayDistance ;
261+ raycastHit . transform = result . gameObject . transform ;
262+ raycastHit . raycastValid = true ;
263+
258264 graphicsRaycastResult = result ;
259265
260266 this . hitObject = result . gameObject ;
@@ -552,12 +558,19 @@ private void UpdateGazeProvider()
552558 // another raycast if it's not populated
553559 if ( gazeHitResult == null )
554560 {
561+ // get 3d hit
555562 hitResult3d . Clear ( ) ;
556563 var raycastProvider = CoreServices . InputSystem . RaycastProvider ;
557564 LayerMask [ ] prioritizedLayerMasks = ( gazeProviderPointingData . Pointer . PrioritizedLayerMasksOverride ?? FocusLayerMasks ) ;
558565 QueryScene ( gazeProviderPointingData . Pointer , raycastProvider , prioritizedLayerMasks ,
559566 hitResult3d , maxQuerySceneResults , focusIndividualCompoundCollider ) ;
560- gazeHitResult = hitResult3d ;
567+
568+ // get ui hit
569+ hitResultUi . Clear ( ) ;
570+ RaycastGraphics ( gazeProviderPointingData . Pointer , gazeProviderPointingData . GraphicEventData , prioritizedLayerMasks , hitResultUi ) ;
571+
572+ // set gaze hit according to distance and priorization layer mask
573+ gazeHitResult = GetPrioritizedHitResult ( hitResult3d , hitResultUi , prioritizedLayerMasks ) ;
561574 }
562575
563576 CoreServices . InputSystem . GazeProvider . UpdateGazeInfoFromHit ( gazeHitResult . raycastHit ) ;
@@ -957,11 +970,6 @@ private void UpdatePointer(PointerData pointerData)
957970 hitResult3d . Clear ( ) ;
958971 QueryScene ( pointerData . Pointer , raycastProvider , prioritizedLayerMasks , hitResult3d , maxQuerySceneResults , focusIndividualCompoundCollider ) ;
959972
960- if ( pointerData . Pointer . PointerId == gazeProviderPointingData . Pointer . PointerId )
961- {
962- gazeHitResult = hitResult3d ;
963- }
964-
965973 int hitResult3dLayer = hitResult3d . hitObject != null ? hitResult3d . hitObject . layer : - 1 ;
966974 if ( hitResult3dLayer == 0 )
967975 {
@@ -997,6 +1005,12 @@ private void UpdatePointer(PointerData pointerData)
9971005 // Apply the hit result only now so changes in the current target are detected only once per frame.
9981006 pointerData . UpdateHit ( hit ) ;
9991007
1008+ // set gaze hit result - make sure to include unity ui hits
1009+ if ( pointerData . Pointer . PointerId == gazeProviderPointingData . Pointer . PointerId )
1010+ {
1011+ gazeHitResult = hit ;
1012+ }
1013+
10001014 // Set the pointer's result last
10011015 pointerData . Pointer . Result = pointerData ;
10021016 }
0 commit comments