|
3 | 3 |
|
4 | 4 | using Microsoft.MixedReality.Toolkit.Core.Definitions.Utilities; |
5 | 5 | using Microsoft.MixedReality.Toolkit.Core.EventDatum.Input; |
| 6 | +using Microsoft.MixedReality.Toolkit.Core.Interfaces; |
6 | 7 | using Microsoft.MixedReality.Toolkit.Core.Interfaces.Devices; |
7 | 8 | using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem.Handlers; |
8 | 9 | using Microsoft.MixedReality.Toolkit.Core.Managers; |
| 10 | +using System.Collections.Generic; |
9 | 11 | using UnityEngine; |
10 | 12 |
|
11 | 13 | namespace Microsoft.MixedReality.Toolkit.SDK.Utilities.Solvers |
@@ -34,14 +36,14 @@ public Handedness Handedness |
34 | 36 |
|
35 | 37 | protected Transform ControllerTransform; |
36 | 38 |
|
37 | | - private IMixedRealityDeviceManager BaseDeviceManager => baseDeviceManager ?? (baseDeviceManager = MixedRealityManager.Instance.GetManager<IMixedRealityDeviceManager>()); |
38 | | - private IMixedRealityDeviceManager baseDeviceManager = null; |
| 39 | + private IEnumerable<IMixedRealityManager> BaseDeviceManagers => baseDeviceManagers ?? (baseDeviceManagers = MixedRealityManager.Instance.GetManagers(typeof(IMixedRealityDeviceManager))); |
| 40 | + private IEnumerable<IMixedRealityManager> baseDeviceManagers = null; |
39 | 41 |
|
40 | 42 | #region MonoBehaviour Implementation |
41 | 43 |
|
42 | 44 | protected virtual void OnEnable() |
43 | 45 | { |
44 | | - if (BaseDeviceManager == null) |
| 46 | + if (BaseDeviceManagers == null) |
45 | 47 | { |
46 | 48 | // The base device manager has not been set up yet. |
47 | 49 | return; |
@@ -80,20 +82,24 @@ protected virtual void TryAndAddControllerTransform() |
80 | 82 | { |
81 | 83 | // Look if the controller was already loaded. This could happen if the |
82 | 84 | // GameObject was instantiated at runtime and the model loaded event has already fired. |
83 | | - if (BaseDeviceManager == null) |
| 85 | + if (BaseDeviceManagers == null) |
84 | 86 | { |
85 | 87 | // The BaseDeviceManager could not be found. |
86 | 88 | return; |
87 | 89 | } |
88 | 90 |
|
89 | | - IMixedRealityController[] controllers = BaseDeviceManager.GetActiveControllers(); |
90 | | - |
91 | | - for (int i = 0; i < controllers.Length; i++) |
| 91 | + foreach (IMixedRealityDeviceManager manager in BaseDeviceManagers) |
92 | 92 | { |
93 | | - if (controllers[i].ControllerHandedness == handedness) |
| 93 | + IMixedRealityController[] controllers = manager.GetActiveControllers(); |
| 94 | + |
| 95 | + for (int i = 0; i < controllers.Length; i++) |
94 | 96 | { |
95 | | - AddControllerTransform(controllers[i]); |
96 | | - return; |
| 97 | + if (controllers[i].ControllerHandedness == handedness) |
| 98 | + { |
| 99 | + AddControllerTransform(controllers[i]); |
| 100 | + return; |
| 101 | + } |
| 102 | + |
97 | 103 | } |
98 | 104 | } |
99 | 105 | } |
|
0 commit comments