Skip to content

Commit c9b54d4

Browse files
author
David Kline
authored
Merge pull request #2376 from StephenHodgson/MRTK-vNEXT-Checks
Added asserts for things
2 parents 8674de9 + 8adc0d1 commit c9b54d4

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

Assets/MixedRealityToolkit/InputSystem/Focus/FocusProvider.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,9 @@ private void Awake()
228228

229229
private void Start()
230230
{
231+
Debug.Assert(MixedRealityManager.IsInitialized, "No Mixed Reality Manager found in the scene. Be sure to run the Mixed Reality Configuration.");
232+
Debug.Assert(InputSystem != null, "No Input System found, Did you set it up in your configuration profile?");
233+
231234
// Register the FocusProvider as a global listener to get input events.
232235
InputSystem.Register(gameObject);
233236
}

Assets/MixedRealityToolkit/InputSystem/Gaze/GazeProvider.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ protected virtual void OnEnable()
208208

209209
private void Start()
210210
{
211+
Debug.Assert(MixedRealityManager.IsInitialized, "No Mixed Reality Manager found in the scene. Be sure to run the Mixed Reality Configuration.");
212+
Debug.Assert(InputSystem != null, "No Input System found, Did you set it up in your configuration profile?");
213+
211214
if (cursorPrefab != null)
212215
{
213216
var cursorObj = Instantiate(cursorPrefab, transform);

Assets/MixedRealityToolkit/_Core/Utilities/CameraCache.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,15 @@ public static class CameraCache
1616
/// <summary>
1717
/// Returns a cached reference to the main camera and uses Camera.main if it hasn't been cached yet.
1818
/// </summary>
19-
public static Camera Main
20-
{
21-
get
22-
{
23-
if (cachedCamera == null)
24-
{
25-
return Refresh(Camera.main);
26-
}
27-
return cachedCamera;
28-
}
29-
}
19+
public static Camera Main => cachedCamera == null ? Refresh(Camera.main) : cachedCamera;
3020

3121
/// <summary>
3222
/// Set the cached camera to a new reference and return it
3323
/// </summary>
3424
/// <param name="newMain">New main camera to cache</param>
3525
public static Camera Refresh(Camera newMain)
3626
{
27+
Debug.Assert(newMain != null, "No camera with MainCamera tag found in scene. Did you forget to tag your camera?");
3728
return cachedCamera = newMain;
3829
}
3930
}

0 commit comments

Comments
 (0)