Skip to content

Commit 5ed24ec

Browse files
author
David Kline (ANALOG)
committed
null check pr feedback
1 parent 5ae9a14 commit 5ed24ec

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed

Assets/MixedRealityToolkit.Services/BoundarySystem/MixedRealityBoundarySystem.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public MixedRealityBoundarySystem(
2929
ExperienceScale scale) : base(registrar, profile)
3030
{
3131
Scale = scale;
32+
33+
if (playspace == null)
34+
{
35+
Debug.LogError("The MixedRealityBoundarySystem object requires a valid playspace Transform.");
36+
}
3237
Playspace = playspace;
3338
}
3439

Assets/MixedRealityToolkit.Services/DiagnosticsSystem/MixedRealityDiagnosticsSystem.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ public MixedRealityDiagnosticsSystem(
2121
MixedRealityDiagnosticsProfile profile,
2222
Transform playspace) : base(registrar, profile)
2323
{
24+
if (playspace == null)
25+
{
26+
Debug.LogError("The MixedRealityDiagnosticSystem object requires a valid playspace Transform.");
27+
}
2428
Playspace = playspace;
2529
}
2630

Assets/MixedRealityToolkit.Services/InputSystem/FocusProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ public void OnSourceLost(SourceStateEventData eventData)
942942
if (gazeProviderPointingData != null && eventData.InputSource.Pointers[i].PointerId == gazeProviderPointingData.Pointer.PointerId)
943943
{
944944
// If the source lost is the gaze input source, then reset it.
945-
if (eventData.InputSource.SourceId == ((IMixedRealityInputSystem)Service).GazeProvider.GazeInputSource.SourceId)
945+
if (eventData.InputSource.SourceId == ((IMixedRealityInputSystem)Service).GazeProvider?.GazeInputSource.SourceId)
946946
{
947947
gazeProviderPointingData.ResetFocusedObjects();
948948
gazeProviderPointingData = null;

Assets/MixedRealityToolkit.Services/InputSystem/MixedRealityInputSystem.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ public MixedRealityInputSystem(
3030
MixedRealityInputSystemProfile profile,
3131
Transform playspace) : base(registrar, profile)
3232
{
33+
if (registrar == null)
34+
{
35+
Debug.LogError("The MixedRealityInputSystem object requires a valid IMixedRealityServiceRegistrar instance.");
36+
}
37+
38+
if (playspace == null)
39+
{
40+
Debug.LogError("The MixedRealityInputSystem object requires a valid playspace Transform.");
41+
}
3342
Playspace = playspace;
3443
}
3544

Assets/MixedRealityToolkit.Services/SpatialAwarenessSystem/MixedRealitySpatialAwarenessSystem.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ namespace Microsoft.MixedReality.Toolkit.Services.SpatialAwarenessSystem
2020
public class MixedRealitySpatialAwarenessSystem : BaseCoreSystem, IMixedRealitySpatialAwarenessSystem
2121
{
2222
public MixedRealitySpatialAwarenessSystem(IMixedRealityServiceRegistrar registrar) : base(registrar, null) // spatial awareness does not yet use a profile
23-
{ }
23+
{
24+
if (registrar == null)
25+
{
26+
Debug.LogError("The MixedRealitySpatialAwarenessSystem object requires a valid IMixedRealityServiceRegistrar instance.");
27+
}
28+
}
2429

2530
#region IMixedRealityToolkit Implementation
2631

Assets/MixedRealityToolkit.Services/TeleportSystem/MixedRealityTeleportSystem.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,18 @@ public MixedRealityTeleportSystem(
2121
IMixedRealityServiceRegistrar registrar,
2222
Transform playspace) : base(registrar, null) // Teleport system does not use a profile
2323
{
24-
Playspace = playspace;
24+
if (registrar == null)
25+
{
26+
Debug.LogError("The MixedRealityTeleportSystem object requires a valid IMixedRealityServiceRegistrar instance.");
27+
}
2528
IsInputSystemEnabled = (registrar.GetService<IMixedRealityInputSystem>(showLogs: false) != null);
29+
30+
if (playspace == null)
31+
{
32+
Debug.LogError("The MixedRealityTeleportSystem object requires a valid playspace Transform.");
33+
}
34+
35+
Playspace = playspace;
2636
}
2737

2838
private TeleportEventData teleportEventData;

0 commit comments

Comments
 (0)