Skip to content

Commit 8e5ee20

Browse files
Merge pull request #864 from Zod-/CameraCache
Fix null coalescing causing errors
2 parents 4451dcb + 5a3d8f3 commit 8e5ee20

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

Assets/HoloToolkit/Input/Scripts/Gaze/GazeManager.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,12 @@ private void Update()
138138

139139
private bool FindGazeTransform()
140140
{
141-
GazeTransform = GazeTransform ?? CameraCache.Main.transform;
142-
if (GazeTransform != null) return true;
141+
if (GazeTransform != null) { return true; }
142+
if (CameraCache.Main != null)
143+
{
144+
GazeTransform = CameraCache.Main.transform;
145+
return true;
146+
}
143147

144148
Debug.LogError("Gaze Manager was not given a GazeTransform and no main camera exists to default to.");
145149
return false;

Assets/HoloToolkit/Utilities/Scripts/CameraCache.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ public static Camera Main
2020
{
2121
get
2222
{
23-
return cachedCamera ?? Refresh(Camera.main);
23+
if (cachedCamera == null)
24+
{
25+
return Refresh(Camera.main);
26+
}
27+
return cachedCamera;
2428
}
2529
}
2630

0 commit comments

Comments
 (0)