@@ -54,6 +54,7 @@ public class VRHead : MonoBehaviour
5454 private Camera _camera ;
5555 private DeviceDescriptor _deviceDescriptor ;
5656 private OsvrDistortion _distortionEffect ;
57+ private DisplayInterface _displayInterface ;
5758 private bool _initDisplayInterface = false ;
5859 #endregion
5960
@@ -68,27 +69,30 @@ void Start()
6869 _distortionEffect . enabled = ( viewMode == ViewMode . mono ) ;
6970 }
7071
72+ _displayInterface = GetComponent < DisplayInterface > ( ) ;
73+
7174 //update VRHead with info from the display interface if it has been initialized
7275 //it might not be initialized if it is still parsing a display json file
7376 //in that case, we will try to initialize asap in the update function
74- if ( GetComponent < DisplayInterface > ( ) . Initialized )
77+ if ( _displayInterface != null && _displayInterface . Initialized )
7578 {
7679 UpdateDisplayInterface ( ) ;
77- }
80+ }
81+ //else initialize in Update()
7882 }
7983 #endregion
8084
8185 #region Loop
8286 void Update ( )
8387 {
84-
85- if ( ! _initDisplayInterface && ! GetComponent < DisplayInterface > ( ) . Initialized )
88+
89+ if ( ! _initDisplayInterface && ! _displayInterface . Initialized )
8690 {
8791 //if the display configuration hasn't initialized, ping the DisplayInterface to retrieve it from the ClientKit
8892 //this would mean DisplayInterface was unable to retrieve that data in its Start() function.
8993 GetComponent < DisplayInterface > ( ) . ReadDisplayPath ( ) ;
9094 }
91- else if ( ! _initDisplayInterface && GetComponent < DisplayInterface > ( ) . Initialized )
95+ else if ( ! _initDisplayInterface && _displayInterface . Initialized )
9296 {
9397 //once the DisplayInterface has initialized, meaning it has read data from the /display path which contains
9498 //display configuration, update the Camera and other settings with properties from the display configuration.
0 commit comments