@@ -28,12 +28,6 @@ public struct RaycastResult
2828
2929 private GazeManager gazeManager ;
3030
31- /// <summary>
32- /// The number of frames to wait until we get our GazeManager reference before
33- /// throwing an error about it being missing in the scene.
34- /// </summary>
35- private int framesBeforeError = 10 ;
36-
3731 protected virtual void Awake ( )
3832 {
3933 meshRenderer = gameObject . GetComponent < MeshRenderer > ( ) ;
@@ -51,32 +45,20 @@ protected virtual void Awake()
5145 cursorDefaultRotation = gameObject . transform . rotation ;
5246 }
5347
54- private bool GetGazeManagerReference ( )
48+ protected virtual void Start ( )
5549 {
5650 gazeManager = GazeManager . Instance ;
5751
5852 if ( gazeManager == null )
5953 {
60- if ( framesBeforeError > 0 )
61- {
62- framesBeforeError -- ;
63- }
64-
65- if ( framesBeforeError == 0 )
66- {
67- Debug . LogError ( "Must have a GazeManager somewhere in the scene." ) ;
68- }
69-
70- return false ;
54+ Debug . LogError ( "Must have a GazeManager somewhere in the scene." ) ;
7155 }
7256
7357 if ( ( GazeManager . Instance . RaycastLayerMask & ( 1 << gameObject . layer ) ) != 0 )
7458 {
7559 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: " +
7660 LayerMask . LayerToName ( gameObject . layer ) ) ;
7761 }
78-
79- return true ;
8062 }
8163
8264 protected virtual RaycastResult CalculateRayIntersect ( )
@@ -90,19 +72,11 @@ protected virtual RaycastResult CalculateRayIntersect()
9072
9173 protected virtual void LateUpdate ( )
9274 {
93- if ( meshRenderer == null )
75+ if ( meshRenderer == null || gazeManager == null )
9476 {
9577 return ;
9678 }
9779
98- if ( gazeManager == null )
99- {
100- if ( ! GetGazeManagerReference ( ) )
101- {
102- return ;
103- }
104- }
105-
10680 // Calculate the raycast result
10781 RaycastResult rayResult = CalculateRayIntersect ( ) ;
10882
0 commit comments