Skip to content

Commit f1f4f42

Browse files
Fix TouchPointer NullReferenceException (#11036)
1 parent 7ebc9b3 commit f1f4f42

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Assets/MRTK/SDK/Features/UX/Interactable/Scripts/Interactable.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ protected virtual bool ShouldListenToUpDownEvent(InputEventData data)
11991199
int focusingPokePointerCount = 0;
12001200
for (int i = 0; i < focusingPointers.Count; i++)
12011201
{
1202-
if (focusingPointers[i].InputSourceParent.SourceId == data.SourceId)
1202+
if (focusingPointers[i].InputSourceParent != null && focusingPointers[i].InputSourceParent.SourceId == data.SourceId)
12031203
{
12041204
focusingPointerCount++;
12051205
if (focusingPointers[i] is PokePointer)
@@ -1224,7 +1224,9 @@ private bool IsInputFromNearInteraction(InputEventData eventData)
12241224
bool isAnyNearpointerFocusing = false;
12251225
for (int i = 0; i < focusingPointers.Count; i++)
12261226
{
1227-
if (focusingPointers[i].InputSourceParent.SourceId == eventData.InputSource.SourceId && focusingPointers[i] is IMixedRealityNearPointer)
1227+
if (focusingPointers[i].InputSourceParent != null &&
1228+
focusingPointers[i].InputSourceParent.SourceId == eventData.InputSource.SourceId &&
1229+
focusingPointers[i] is IMixedRealityNearPointer)
12281230
{
12291231
isAnyNearpointerFocusing = true;
12301232
break;

Assets/MRTK/SDK/Features/UX/Scripts/Cursors/BaseCursor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ public virtual void OnPointerClicked(MixedRealityPointerEventData eventData) { }
330330
/// <inheritdoc />
331331
public virtual void OnPointerUp(MixedRealityPointerEventData eventData)
332332
{
333-
if (IsPointerValid)
333+
if (IsPointerValid && eventData.InputSource != null)
334334
{
335335
foreach (var sourcePointer in eventData.InputSource.Pointers)
336336
{

0 commit comments

Comments
 (0)