Skip to content

Commit 10ad776

Browse files
committed
fix(SDK): prevent null exception if no controller model found
The SteamVR Controller SDK could potentially throw an exception if no controller model was found because the `Transform.Find` method could potentially find `null` but the `gameObject` getter was being chained on the end of the `Find` call. The fix is to split the line into two and do a null check before attempting to get the gameObject.
1 parent f052224 commit 10ad776

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Assets/VRTK/SDK/SteamVR/SDK_SteamVRController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,8 @@ public override GameObject GetControllerModel(ControllerHand hand)
333333

334334
if (controller != null)
335335
{
336-
model = controller.transform.Find("Model").gameObject;
336+
Transform foundModel = controller.transform.Find("Model");
337+
model = (foundModel != null ? foundModel.gameObject : null);
337338
}
338339
}
339340
return model;

0 commit comments

Comments
 (0)