Skip to content

Commit 7b6ef50

Browse files
committed
Fix Unity null propagation
1 parent 22ab0be commit 7b6ef50

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

Assets/MixedRealityToolkit.Services/InputSimulation/SimulatedGestureHand.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ private void EnsureProfileSettings()
5959
}
6060
initializedFromProfile = true;
6161

62-
var gestureProfile = CoreServices.InputSystem?.InputSystemProfile?.GesturesProfile;
62+
MixedRealityGesturesProfile gestureProfile = null;
63+
MixedRealityInputSystemProfile inputSystemProfile = CoreServices.InputSystem?.InputSystemProfile;
64+
if (inputSystemProfile != null)
65+
{
66+
gestureProfile = inputSystemProfile.GesturesProfile;
67+
}
6368
if (gestureProfile != null)
6469
{
6570
for (int i = 0; i < gestureProfile.Gestures.Length; i++)

Assets/MixedRealityToolkit.Services/InputSystem/MixedRealityInputSystem.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,10 +248,10 @@ private void CreateDataProviders()
248248
MixedRealityInputSystemProfile profile = ConfigurationProfile as MixedRealityInputSystemProfile;
249249

250250
// If the system gets disabled, the gaze provider is destroyed.
251-
// Ensure that it gets recreated on when reenabled.
252-
if (GazeProvider == null)
251+
// Ensure that it gets recreated on when re-enabled.
252+
if (GazeProvider == null && profile != null)
253253
{
254-
InstantiateGazeProvider(profile?.PointerProfile);
254+
InstantiateGazeProvider(profile.PointerProfile);
255255
}
256256

257257
if ((GetDataProviders().Count == 0) && (profile != null))
@@ -272,7 +272,7 @@ private void CreateDataProviders()
272272

273273
private void InstantiateGazeProvider(MixedRealityPointerProfile pointerProfile)
274274
{
275-
if (pointerProfile?.GazeProviderType?.Type != null)
275+
if (pointerProfile != null && pointerProfile.GazeProviderType?.Type != null)
276276
{
277277
GazeProvider = CameraCache.Main.gameObject.EnsureComponent(pointerProfile.GazeProviderType.Type) as IMixedRealityGazeProvider;
278278
GazeProvider.GazeCursorPrefab = pointerProfile.GazeCursorPrefab;
@@ -991,7 +991,12 @@ public void RaiseFocusExit(IMixedRealityPointer pointer, GameObject unfocusedObj
991991
public void RaisePointerDown(IMixedRealityPointer pointer, MixedRealityInputAction inputAction, Handedness handedness = Handedness.None, IMixedRealityInputSource inputSource = null)
992992
{
993993
// Only lock the object if there is a grabbable above in the hierarchy
994-
Transform currentObject = pointer.Result?.Details.Object?.transform;
994+
Transform currentObject = null;
995+
GameObject currentGameObject = pointer.Result?.Details.Object;
996+
if (currentGameObject != null)
997+
{
998+
currentObject = currentGameObject.transform;
999+
}
9951000
IMixedRealityPointerHandler ancestorPointerHandler = null;
9961001
while(currentObject != null && ancestorPointerHandler == null)
9971002
{

0 commit comments

Comments
 (0)