Skip to content

Commit 5d352c7

Browse files
author
David Kline
authored
Merge pull request #3808 from wiwei/nullparentfix
Add a null input parent check in DefaultPointerMediator
2 parents a965484 + c7e78d7 commit 5d352c7

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

Assets/MixedRealityToolkit.SDK/Features/UX/Scripts/Pointers/DefaultPointerMediator.cs

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ public void RegisterPointers(IMixedRealityPointer[] pointers)
3636
farInteractPointers.Add(pointer);
3737
}
3838

39-
HashSet<IMixedRealityPointer> children;
40-
if (!pointerByInputSourceParent.TryGetValue(pointer.InputSourceParent, out children))
39+
if (pointer.InputSourceParent != null)
4140
{
42-
children = new HashSet<IMixedRealityPointer>();
43-
pointerByInputSourceParent.Add(pointer.InputSourceParent, children);
41+
HashSet<IMixedRealityPointer> children;
42+
if (!pointerByInputSourceParent.TryGetValue(pointer.InputSourceParent, out children))
43+
{
44+
children = new HashSet<IMixedRealityPointer>();
45+
pointerByInputSourceParent.Add(pointer.InputSourceParent, children);
46+
}
47+
children.Add(pointer);
4448
}
45-
children.Add(pointer);
4649
}
4750
}
4851

@@ -99,15 +102,18 @@ public void UpdatePointers()
99102
pointer.IsActive = true;
100103
unassignedPointers.Remove(pointer);
101104

102-
foreach (IMixedRealityPointer otherPointer in pointerByInputSourceParent[pointer.InputSourceParent])
105+
if (pointer.InputSourceParent != null)
103106
{
104-
if (!unassignedPointers.Contains(otherPointer))
107+
foreach (IMixedRealityPointer otherPointer in pointerByInputSourceParent[pointer.InputSourceParent])
105108
{
106-
continue;
107-
}
109+
if (!unassignedPointers.Contains(otherPointer))
110+
{
111+
continue;
112+
}
108113

109-
otherPointer.IsActive = false;
110-
unassignedPointers.Remove(otherPointer);
114+
otherPointer.IsActive = false;
115+
unassignedPointers.Remove(otherPointer);
116+
}
111117
}
112118
}
113119
}
@@ -126,15 +132,18 @@ public void UpdatePointers()
126132
pointer.IsActive = true;
127133
unassignedPointers.Remove(pointer);
128134

129-
foreach (IMixedRealityPointer otherPointer in pointerByInputSourceParent[pointer.InputSourceParent])
135+
if (pointer.InputSourceParent != null)
130136
{
131-
if (!unassignedPointers.Contains(otherPointer))
137+
foreach (IMixedRealityPointer otherPointer in pointerByInputSourceParent[pointer.InputSourceParent])
132138
{
133-
continue;
134-
}
139+
if (!unassignedPointers.Contains(otherPointer))
140+
{
141+
continue;
142+
}
135143

136-
otherPointer.IsActive = false;
137-
unassignedPointers.Remove(otherPointer);
144+
otherPointer.IsActive = false;
145+
unassignedPointers.Remove(otherPointer);
146+
}
138147
}
139148
}
140149
}

0 commit comments

Comments
 (0)