@@ -512,14 +512,16 @@ public override void Initialize()
512
512
FindOrCreateUiRaycastCamera ( ) ;
513
513
}
514
514
515
- var primaryPointerSelectorType = CoreServices . InputSystem ? . InputSystemProfile . PointerProfile . PrimaryPointerSelector . Type ;
515
+ var inputSystem = CoreServices . InputSystem ;
516
+
517
+ var primaryPointerSelectorType = inputSystemProfile . PointerProfile . PrimaryPointerSelector . Type ;
516
518
if ( primaryPointerSelectorType != null )
517
519
{
518
520
primaryPointerSelector = Activator . CreateInstance ( primaryPointerSelectorType ) as IMixedRealityPrimaryPointerSelector ;
519
521
primaryPointerSelector . Initialize ( ) ;
520
522
}
521
523
522
- foreach ( var inputSource in CoreServices . InputSystem . DetectedInputSources )
524
+ foreach ( var inputSource in inputSystem . DetectedInputSources )
523
525
{
524
526
RegisterPointers ( inputSource ) ;
525
527
}
@@ -576,18 +578,22 @@ private void UpdateGazeProvider()
576
578
{
577
579
using ( UpdateGazeProviderPerfMarker . Auto ( ) )
578
580
{
581
+ var inputSystem = CoreServices . InputSystem ;
582
+ IMixedRealityGazeProvider gazeProvider = inputSystem . GazeProvider ;
583
+
584
+ bool gazeProviderEnabled = gazeProvider . IsNotNull ( ) && gazeProvider . Enabled ;
579
585
// The gaze hit result may be populated from the UpdatePointers call. If it has not, then perform
580
586
// another raycast if it's not populated
581
- if ( gazeHitResult == null )
587
+ if ( gazeProviderEnabled && gazeHitResult == null )
582
588
{
583
- IMixedRealityPointer gazePointer = CoreServices . InputSystem . GazeProvider ? . GazePointer ;
589
+ IMixedRealityPointer gazePointer = gazeProvider ? . GazePointer ;
584
590
// Check that the gazePointer isn't null and that it has been properly registered as a pointer.
585
591
if ( gazePointer != null && gazeProviderPointingData != null )
586
592
{
587
593
// get 3d hit
588
594
// This is unneccessary since the gaze pointer has been registered normally along with the other pointers(?)
589
595
hitResult3d . Clear ( ) ;
590
- var raycastProvider = CoreServices . InputSystem . RaycastProvider ;
596
+ var raycastProvider = inputSystem . RaycastProvider ;
591
597
LayerMask [ ] prioritizedLayerMasks = ( gazePointer . PrioritizedLayerMasksOverride ?? FocusLayerMasks ) ;
592
598
QueryScene ( gazePointer , raycastProvider , prioritizedLayerMasks ,
593
599
hitResult3d , maxQuerySceneResults , focusIndividualCompoundCollider ) ;
@@ -608,9 +614,9 @@ private void UpdateGazeProvider()
608
614
}
609
615
}
610
616
611
- if ( ! CoreServices . InputSystem . GazeProvider . IsNull ( ) )
617
+ if ( gazeProvider . IsNotNull ( ) && gazeHitResult . IsNotNull ( ) )
612
618
{
613
- CoreServices . InputSystem . GazeProvider . UpdateGazeInfoFromHit ( gazeHitResult . raycastHit ) ;
619
+ gazeProvider . UpdateGazeInfoFromHit ( gazeHitResult . raycastHit ) ;
614
620
}
615
621
616
622
// Zero out value after every use to ensure the hit result is updated every frame.
@@ -705,7 +711,7 @@ public uint GenerateNewPointerId()
705
711
/// <returns>The UIRaycastCamera</returns>
706
712
private void FindOrCreateUiRaycastCamera ( )
707
713
{
708
- GameObject cameraObject = null ;
714
+ GameObject cameraObject ;
709
715
710
716
var existingUiRaycastCameraObject = GameObject . Find ( "UIRaycastCamera" ) ;
711
717
if ( existingUiRaycastCameraObject != null )
@@ -802,9 +808,12 @@ private void RegisterPointers(IMixedRealityInputSource inputSource)
802
808
return ;
803
809
}
804
810
811
+ var inputSystem = CoreServices . InputSystem ;
812
+ IMixedRealityGazeProvider gazeProvider = inputSystem ? . GazeProvider ;
813
+
805
814
IMixedRealityPointerMediator mediator = null ;
806
815
807
- var mediatorType = CoreServices . InputSystem ? . InputSystemProfile . PointerProfile . PointerMediator . Type ;
816
+ var mediatorType = inputSystemProfile . PointerProfile . PointerMediator . Type ;
808
817
if ( mediatorType != null )
809
818
{
810
819
try
@@ -840,8 +849,8 @@ private void RegisterPointers(IMixedRealityInputSource inputSource)
840
849
841
850
// Special Registration for Gaze
842
851
// Refreshes gazeProviderPointingData to a new reference to the current EventSystem
843
- if ( ! CoreServices . InputSystem . GazeProvider . IsNull ( )
844
- && inputSource . SourceId == CoreServices . InputSystem . GazeProvider . GazeInputSource . SourceId
852
+ if ( ! gazeProvider . IsNull ( )
853
+ && inputSource . SourceId == gazeProvider . GazeInputSource . SourceId
845
854
&& gazeProviderPointingData == null )
846
855
{
847
856
gazeProviderPointingData = new PointerEventData ( EventSystem . current ) ;
@@ -879,15 +888,17 @@ public bool UnregisterPointer(IMixedRealityPointer pointer)
879
888
}
880
889
}
881
890
882
- CoreServices . InputSystem ? . RaisePreFocusChanged ( pointer , unfocusedObject , null ) ;
891
+ var inputSystem = CoreServices . InputSystem ;
892
+
893
+ inputSystem ? . RaisePreFocusChanged ( pointer , unfocusedObject , null ) ;
883
894
884
895
if ( ! objectIsStillFocusedByOtherPointer )
885
896
{
886
897
// Policy: only raise focus exit if no other pointers are still focusing the object
887
- CoreServices . InputSystem ? . RaiseFocusExit ( pointer , unfocusedObject ) ;
898
+ inputSystem ? . RaiseFocusExit ( pointer , unfocusedObject ) ;
888
899
}
889
900
890
- CoreServices . InputSystem ? . RaiseFocusChanged ( pointer , unfocusedObject , null ) ;
901
+ inputSystem ? . RaiseFocusChanged ( pointer , unfocusedObject , null ) ;
891
902
}
892
903
893
904
pointers . Remove ( pointerData . Pointer . PointerId ) ;
@@ -1014,6 +1025,7 @@ private void UpdatePointer(PointerData pointerData)
1014
1025
{
1015
1026
using ( UpdatePointerPerfMarker . Auto ( ) )
1016
1027
{
1028
+
1017
1029
// Call the pointer's OnPreSceneQuery function
1018
1030
// This will give it a chance to prepare itself for raycasts
1019
1031
// e.g., by building its Rays array
@@ -1027,6 +1039,8 @@ private void UpdatePointer(PointerData pointerData)
1027
1039
}
1028
1040
else
1029
1041
{
1042
+ var inputSystem = CoreServices . InputSystem ;
1043
+
1030
1044
LayerMask [ ] prioritizedLayerMasks = ( pointerData . Pointer . PrioritizedLayerMasksOverride ?? FocusLayerMasks ) ;
1031
1045
1032
1046
if ( pointerData . IsCurrentPointerTargetInvalid )
@@ -1052,7 +1066,7 @@ private void UpdatePointer(PointerData pointerData)
1052
1066
else
1053
1067
{
1054
1068
// Perform raycast to determine focused object
1055
- var raycastProvider = CoreServices . InputSystem . RaycastProvider ;
1069
+ var raycastProvider = inputSystem . RaycastProvider ;
1056
1070
hitResult3d . Clear ( ) ;
1057
1071
QueryScene ( pointerData . Pointer , raycastProvider , prioritizedLayerMasks , hitResult3d , maxQuerySceneResults , focusIndividualCompoundCollider ) ;
1058
1072
@@ -1092,7 +1106,7 @@ private void UpdatePointer(PointerData pointerData)
1092
1106
pointerData . UpdateHit ( hit ) ;
1093
1107
1094
1108
// set gaze hit result - make sure to include unity ui hits
1095
- var gazePointer = CoreServices . InputSystem . GazeProvider . GazePointer ;
1109
+ var gazePointer = inputSystem . GazeProvider . GazePointer ;
1096
1110
if ( gazePointer != null && pointerData . Pointer . PointerId == gazePointer . PointerId )
1097
1111
{
1098
1112
gazeHitResult = hit ;
@@ -1170,7 +1184,9 @@ private void ReconcilePointers()
1170
1184
{
1171
1185
using ( ReconcilePointersPerfMarker . Auto ( ) )
1172
1186
{
1173
- var gazePointer = CoreServices . InputSystem . GazeProvider ? . GazePointer as GenericPointer ;
1187
+ var inputSystem = CoreServices . InputSystem ;
1188
+
1189
+ var gazePointer = inputSystem . GazeProvider ? . GazePointer as GenericPointer ;
1174
1190
NumFarPointersActive = 0 ;
1175
1191
NumNearPointersActive = 0 ;
1176
1192
int numFarPointersWithoutCursorActive = 0 ;
@@ -1208,7 +1224,7 @@ private void ReconcilePointers()
1208
1224
NumNearPointersActive ,
1209
1225
NumFarPointersActive ,
1210
1226
numFarPointersWithoutCursorActive ,
1211
- CoreServices . InputSystem . EyeGazeProvider . IsEyeTrackingEnabledAndValid ) ;
1227
+ inputSystem . EyeGazeProvider . IsEyeTrackingEnabledAndValid ) ;
1212
1228
1213
1229
bool isGazePointerActive = gazePointerStateMachine . IsGazePointerActive ;
1214
1230
@@ -1547,14 +1563,15 @@ private void UpdateFocusedObjects()
1547
1563
pendingOverallFocusEnterSet . Remove ( pointer . PreviousPointerTarget ) ;
1548
1564
}
1549
1565
1566
+ var inputSystem = CoreServices . InputSystem ;
1550
1567
// Now we raise the events:
1551
1568
for ( int iChange = 0 ; iChange < pendingPointerSpecificFocusChange . Count ; iChange ++ )
1552
1569
{
1553
1570
PointerData change = pendingPointerSpecificFocusChange [ iChange ] ;
1554
1571
GameObject pendingUnfocusObject = change . PreviousPointerTarget ;
1555
1572
GameObject pendingFocusObject = change . CurrentPointerTarget ;
1556
1573
1557
- CoreServices . InputSystem . RaisePreFocusChanged ( change . Pointer , pendingUnfocusObject , pendingFocusObject ) ;
1574
+ inputSystem . RaisePreFocusChanged ( change . Pointer , pendingUnfocusObject , pendingFocusObject ) ;
1558
1575
1559
1576
int numExits ;
1560
1577
if ( pendingUnfocusObject != null && pendingOverallFocusExitSet . TryGetValue ( pendingUnfocusObject , out numExits ) )
@@ -1565,18 +1582,18 @@ private void UpdateFocusedObjects()
1565
1582
}
1566
1583
else
1567
1584
{
1568
- CoreServices . InputSystem . RaiseFocusExit ( change . Pointer , pendingUnfocusObject ) ;
1585
+ inputSystem . RaiseFocusExit ( change . Pointer , pendingUnfocusObject ) ;
1569
1586
pendingOverallFocusExitSet . Remove ( pendingUnfocusObject ) ;
1570
1587
}
1571
1588
}
1572
1589
1573
1590
if ( pendingOverallFocusEnterSet . Contains ( pendingFocusObject ) )
1574
1591
{
1575
- CoreServices . InputSystem . RaiseFocusEnter ( change . Pointer , pendingFocusObject ) ;
1592
+ inputSystem . RaiseFocusEnter ( change . Pointer , pendingFocusObject ) ;
1576
1593
pendingOverallFocusEnterSet . Remove ( pendingFocusObject ) ;
1577
1594
}
1578
1595
1579
- CoreServices . InputSystem . RaiseFocusChanged ( change . Pointer , pendingUnfocusObject , pendingFocusObject ) ;
1596
+ inputSystem . RaiseFocusChanged ( change . Pointer , pendingUnfocusObject , pendingFocusObject ) ;
1580
1597
}
1581
1598
1582
1599
Debug . Assert ( pendingOverallFocusExitSet . Count == 0 ) ;
@@ -1619,15 +1636,16 @@ public void OnSourceLost(SourceStateEventData eventData)
1619
1636
1620
1637
pointerMediators . Remove ( eventData . SourceId ) ;
1621
1638
1639
+ var gazePointer = CoreServices . InputSystem . GazeProvider ? . GazePointer ;
1640
+ var gazeInputSourceId = CoreServices . InputSystem . GazeProvider ? . GazeInputSource . SourceId ;
1622
1641
1623
1642
for ( var i = 0 ; i < eventData . InputSource . Pointers . Length ; i ++ )
1624
1643
{
1625
- var gazePointer = CoreServices . InputSystem . GazeProvider ? . GazePointer ;
1626
1644
// Special unregistration for Gaze
1627
1645
if ( gazePointer != null && eventData . InputSource . Pointers [ i ] . PointerId == gazePointer . PointerId )
1628
1646
{
1629
1647
// If the source lost is the gaze input source, clear gazeProviderPointingData.
1630
- if ( eventData . InputSource . SourceId == CoreServices . InputSystem . GazeProvider ? . GazeInputSource . SourceId )
1648
+ if ( eventData . InputSource . SourceId == gazeInputSourceId )
1631
1649
{
1632
1650
gazeProviderPointingData = null ;
1633
1651
}
0 commit comments