@@ -26,10 +26,14 @@ public struct RaycastResult
2626
2727 private MeshRenderer meshRenderer ;
2828
29- private bool hasLoggedGazeManagerError ;
30-
3129 private GazeManager gazeManager ;
3230
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+
3337 protected virtual void Awake ( )
3438 {
3539 meshRenderer = gameObject . GetComponent < MeshRenderer > ( ) ;
@@ -53,6 +57,16 @@ private bool GetGazeManagerReference()
5357
5458 if ( gazeManager == null )
5559 {
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+
5670 return false ;
5771 }
5872
@@ -68,15 +82,6 @@ private bool GetGazeManagerReference()
6882 protected virtual RaycastResult CalculateRayIntersect ( )
6983 {
7084 RaycastResult result = new RaycastResult ( ) ;
71- if ( GazeManager . Instance == null )
72- {
73- if ( ! hasLoggedGazeManagerError )
74- {
75- Debug . LogError ( "Must have a GazeManager somewhere in the scene." ) ;
76- hasLoggedGazeManagerError = true ;
77- }
78- return result ;
79- }
8085 result . Hit = GazeManager . Instance . Hit ;
8186 result . Position = GazeManager . Instance . Position ;
8287 result . Normal = GazeManager . Instance . Normal ;
0 commit comments