1616using UnityEngine ;
1717using UnityEngine . EventSystems ;
1818using Microsoft . MixedReality . Toolkit . Core . Services ;
19+ using Microsoft . MixedReality . Toolkit . Core . Interfaces ;
1920
2021namespace Microsoft . MixedReality . Toolkit . Services . InputSystem
2122{
2223 /// <summary>
2324 /// The Mixed Reality Toolkit's specific implementation of the <see cref="Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem.IMixedRealityInputSystem"/>
2425 /// </summary>
25- public class MixedRealityInputSystem : BaseEventSystem , IMixedRealityInputSystem
26+ public class MixedRealityInputSystem : BaseCoreSystem , IMixedRealityInputSystem
2627 {
28+ public MixedRealityInputSystem (
29+ IMixedRealityServiceRegistrar registrar ,
30+ MixedRealityInputSystemProfile profile ) : base ( registrar , profile ) { }
31+
2732 /// <inheritdoc />
2833 public event Action InputEnabled ;
2934
@@ -39,7 +44,7 @@ public class MixedRealityInputSystem : BaseEventSystem, IMixedRealityInputSystem
3944 private IMixedRealityFocusProvider focusProvider = null ;
4045
4146 /// <inheritdoc />
42- public IMixedRealityFocusProvider FocusProvider => focusProvider ?? ( focusProvider = MixedRealityToolkit . Instance . GetService < IMixedRealityFocusProvider > ( ) ) ;
47+ public IMixedRealityFocusProvider FocusProvider => focusProvider ?? ( focusProvider = Registrar . GetService < IMixedRealityFocusProvider > ( ) ) ;
4348
4449 /// <inheritdoc />
4550 public IMixedRealityGazeProvider GazeProvider { get ; private set ; }
@@ -88,6 +93,9 @@ public override void Initialize()
8893 {
8994 bool addedComponents = false ;
9095
96+ MixedRealityInputSystemProfile profile = ConfigurationProfile as MixedRealityInputSystemProfile ;
97+ if ( profile == null ) { return ; }
98+
9199 if ( ! Application . isPlaying )
92100 {
93101 var standaloneInputModules = UnityEngine . Object . FindObjectsOfType < StandaloneInputModule > ( ) ;
@@ -125,27 +133,27 @@ public override void Initialize()
125133 CameraCache . Main . gameObject . EnsureComponent < StandaloneInputModule > ( ) ;
126134 }
127135
128- if ( MixedRealityToolkit . Instance . ActiveProfile . InputSystemProfile == null )
136+ if ( profile == null )
129137 {
130138 Debug . LogError ( "The Input system is missing the required Input System Profile!" ) ;
131139 return ;
132140 }
133141
134- if ( MixedRealityToolkit . Instance . ActiveProfile . InputSystemProfile . InputActionRulesProfile != null )
142+ if ( profile . InputActionRulesProfile != null )
135143 {
136- CurrentInputActionRulesProfile = MixedRealityToolkit . Instance . ActiveProfile . InputSystemProfile . InputActionRulesProfile ;
144+ CurrentInputActionRulesProfile = profile . InputActionRulesProfile ;
137145 }
138146 else
139147 {
140148 Debug . LogError ( "The Input system is missing the required Input Action Rules Profile!" ) ;
141149 return ;
142150 }
143151
144- if ( MixedRealityToolkit . Instance . ActiveProfile . InputSystemProfile . PointerProfile != null )
152+ if ( profile . PointerProfile != null )
145153 {
146- if ( MixedRealityToolkit . Instance . ActiveProfile . InputSystemProfile . PointerProfile . GazeProviderType ? . Type != null )
154+ if ( profile . PointerProfile . GazeProviderType ? . Type != null )
147155 {
148- GazeProvider = CameraCache . Main . gameObject . EnsureComponent ( MixedRealityToolkit . Instance . ActiveProfile . InputSystemProfile . PointerProfile . GazeProviderType . Type ) as IMixedRealityGazeProvider ;
156+ GazeProvider = CameraCache . Main . gameObject . EnsureComponent ( profile . PointerProfile . GazeProviderType . Type ) as IMixedRealityGazeProvider ;
149157 }
150158 else
151159 {
0 commit comments