Skip to content

Commit 9d71ff0

Browse files
committed
Update ControllerFinder with component PR changes
1 parent 759f91d commit 9d71ff0

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Assets/MixedRealityToolkit-SDK/Features/Utilities/Solvers/ControllerFinder.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
using Microsoft.MixedReality.Toolkit.Core.Definitions.Utilities;
55
using Microsoft.MixedReality.Toolkit.Core.EventDatum.Input;
6+
using Microsoft.MixedReality.Toolkit.Core.Interfaces;
67
using Microsoft.MixedReality.Toolkit.Core.Interfaces.Devices;
78
using Microsoft.MixedReality.Toolkit.Core.Interfaces.InputSystem.Handlers;
89
using Microsoft.MixedReality.Toolkit.Core.Managers;
10+
using System.Collections.Generic;
911
using UnityEngine;
1012

1113
namespace Microsoft.MixedReality.Toolkit.SDK.Utilities.Solvers
@@ -34,14 +36,14 @@ public Handedness Handedness
3436

3537
protected Transform ControllerTransform;
3638

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;
3941

4042
#region MonoBehaviour Implementation
4143

4244
protected virtual void OnEnable()
4345
{
44-
if (BaseDeviceManager == null)
46+
if (BaseDeviceManagers == null)
4547
{
4648
// The base device manager has not been set up yet.
4749
return;
@@ -80,20 +82,24 @@ protected virtual void TryAndAddControllerTransform()
8082
{
8183
// Look if the controller was already loaded. This could happen if the
8284
// GameObject was instantiated at runtime and the model loaded event has already fired.
83-
if (BaseDeviceManager == null)
85+
if (BaseDeviceManagers == null)
8486
{
8587
// The BaseDeviceManager could not be found.
8688
return;
8789
}
8890

89-
IMixedRealityController[] controllers = BaseDeviceManager.GetActiveControllers();
90-
91-
for (int i = 0; i < controllers.Length; i++)
91+
foreach (IMixedRealityDeviceManager manager in BaseDeviceManagers)
9292
{
93-
if (controllers[i].ControllerHandedness == handedness)
93+
IMixedRealityController[] controllers = manager.GetActiveControllers();
94+
95+
for (int i = 0; i < controllers.Length; i++)
9496
{
95-
AddControllerTransform(controllers[i]);
96-
return;
97+
if (controllers[i].ControllerHandedness == handedness)
98+
{
99+
AddControllerTransform(controllers[i]);
100+
return;
101+
}
102+
97103
}
98104
}
99105
}

0 commit comments

Comments
 (0)