Skip to content

Commit 8a80888

Browse files
committed
Fix GetManager(s) calls in MixedRealityManager
After the component PR, only one GetManager call was updated to actually check the interfaces. The others simply checked against the main type, which is now IMixedRealityComponent and doesn't tell you anything.
1 parent 60e6a6f commit 8a80888

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

Assets/MixedRealityToolkit/_Core/Managers/MixedRealityManager.cs

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -721,24 +721,49 @@ public List<IMixedRealityManager> GetManagers(Type type, string managerName)
721721
}
722722
else
723723
{
724-
//If no name provided, return all components of the same type. Else return the type/name combination.
724+
// If no name provided, return all components of the same type. Else return the type/name combination.
725725
if (string.IsNullOrWhiteSpace(managerName))
726726
{
727727
for (int i = 0; i < mixedRealityComponentsCount; i++)
728728
{
729-
if (MixedRealityComponents[i].Item1.Name == type.Name)
729+
if (MixedRealityComponents[i].Item1.Name == type.Name ||
730+
MixedRealityComponents[i].Item2.GetType().Name == type.Name)
730731
{
731732
managers.Add(MixedRealityComponents[i].Item2);
733+
continue;
734+
}
735+
736+
var interfaces = MixedRealityComponents[i].Item2.GetType().GetInterfaces();
737+
for (int j = 0; j < interfaces.Length; j++)
738+
{
739+
if (interfaces[j].Name == type.Name)
740+
{
741+
managers.Add(MixedRealityComponents[i].Item2);
742+
break;
743+
}
732744
}
733745
}
734746
}
735747
else
736748
{
737749
for (int i = 0; i < mixedRealityComponentsCount; i++)
738750
{
739-
if (MixedRealityComponents[i].Item1.Name == type.Name && MixedRealityComponents[i].Item2.Name == managerName)
751+
if (MixedRealityComponents[i].Item1.Name == type.Name &&
752+
MixedRealityComponents[i].Item2.Name == managerName)
740753
{
741754
managers.Add(MixedRealityComponents[i].Item2);
755+
continue;
756+
}
757+
758+
var interfaces = MixedRealityComponents[i].Item2.GetType().GetInterfaces();
759+
for (int j = 0; j < interfaces.Length; j++)
760+
{
761+
if (interfaces[j].Name == type.Name &&
762+
MixedRealityComponents[i].Item2.Name == managerName)
763+
{
764+
managers.Add(MixedRealityComponents[i].Item2);
765+
break;
766+
}
742767
}
743768
}
744769
}
@@ -942,6 +967,17 @@ private void GetComponentByTypeAndName(Type type, string managerName, out IMixed
942967
manager = MixedRealityComponents[i].Item2;
943968
break;
944969
}
970+
971+
var interfaces = MixedRealityComponents[i].Item2.GetType().GetInterfaces();
972+
for (int j = 0; j < interfaces.Length; j++)
973+
{
974+
if (interfaces[j].Name == type.Name &&
975+
MixedRealityComponents[i].Item2.Name == managerName)
976+
{
977+
manager = MixedRealityComponents[i].Item2;
978+
break;
979+
}
980+
}
945981
}
946982
}
947983

0 commit comments

Comments
 (0)