Skip to content

Commit 0eb5d44

Browse files
Stephen HodgsonStephen Hodgson
authored andcommitted
Fixes GazeManager reference without changing Awake to Start
1 parent 4e64d4a commit 0eb5d44

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

Assets/HoloToolkit/Input/Scripts/BasicCursor.cs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,10 @@ public struct RaycastResult
2828

2929
private bool hasLoggedGazeManagerError;
3030

31-
protected virtual void Start()
32-
{
33-
if ((GazeManager.Instance.RaycastLayerMask & (1 << gameObject.layer)) != 0)
34-
{
35-
Debug.LogError("The cursor has a layer that is checked in the GazeManager's Raycast Layer Mask. Change the cursor layer (e.g.: to Ignore Raycast) or uncheck the layer in GazeManager: " +
36-
LayerMask.LayerToName(gameObject.layer));
37-
}
31+
private GazeManager gazeManagerReference;
3832

33+
protected virtual void Awake()
34+
{
3935
meshRenderer = gameObject.GetComponent<MeshRenderer>();
4036

4137
if (meshRenderer == null)
@@ -51,6 +47,24 @@ protected virtual void Start()
5147
cursorDefaultRotation = gameObject.transform.rotation;
5248
}
5349

50+
private bool GetGazeManagerReference()
51+
{
52+
gazeManagerReference = GazeManager.Instance;
53+
54+
if (gazeManagerReference == null)
55+
{
56+
return false;
57+
}
58+
59+
if ((GazeManager.Instance.RaycastLayerMask & (1 << gameObject.layer)) != 0)
60+
{
61+
Debug.LogError("The cursor has a layer that is checked in the GazeManager's Raycast Layer Mask. Change the cursor layer (e.g.: to Ignore Raycast) or uncheck the layer in GazeManager: " +
62+
LayerMask.LayerToName(gameObject.layer));
63+
}
64+
65+
return true;
66+
}
67+
5468
protected virtual RaycastResult CalculateRayIntersect()
5569
{
5670
RaycastResult result = new RaycastResult();
@@ -76,6 +90,12 @@ protected virtual void LateUpdate()
7690
return;
7791
}
7892

93+
if (gazeManagerReference == null)
94+
{
95+
if (!GetGazeManagerReference())
96+
return;
97+
}
98+
7999
// Calculate the raycast result
80100
RaycastResult rayResult = CalculateRayIntersect();
81101

0 commit comments

Comments
 (0)