@@ -53,6 +53,7 @@ public class VRHead : MonoBehaviour
5353 private Camera _camera ;
5454 private DeviceDescriptor _deviceDescriptor ;
5555 private OsvrDistortion _distortionEffect ;
56+ private bool _initDisplayInterface = false ;
5657 #endregion
5758
5859 #region Init
@@ -65,23 +66,24 @@ void Start()
6566 {
6667 _distortionEffect . enabled = ( viewMode == ViewMode . mono ) ;
6768 }
68- GetDeviceDescription ( ) ;
69- MatchEyes ( ) ; //copy camera properties to each eye
70- //rotate each eye based on overlap percent, must do this after match eyes
71- if ( _deviceDescriptor != null )
69+
70+ //update VRHead with info from the display interface if it has been initialized
71+ //it might not be initialized if it is still loading/parsing a display json file
72+ //in that case, we will try to initialize asap in the update function
73+ if ( GetComponent < DisplayInterface > ( ) . Initialized )
7274 {
73- SetEyeRotation ( _deviceDescriptor . OverlapPercent , _deviceDescriptor . MonocularHorizontal ) ;
74- SetEyeRoll ( _deviceDescriptor . LeftRoll , _deviceDescriptor . RightRoll ) ;
75- }
76-
77-
78-
79- }
75+ UpdateDisplayInterface ( ) ;
76+ }
77+ }
8078 #endregion
8179
8280 #region Loop
8381 void Update ( )
8482 {
83+ if ( ! _initDisplayInterface && GetComponent < DisplayInterface > ( ) . Initialized )
84+ {
85+ UpdateDisplayInterface ( ) ;
86+ }
8587 UpdateStereoAmount ( ) ;
8688 UpdateViewMode ( ) ;
8789 }
@@ -91,6 +93,18 @@ void Update()
9193 #endregion
9294
9395 #region Private Methods
96+ private void UpdateDisplayInterface ( )
97+ {
98+ GetDeviceDescription ( ) ;
99+ MatchEyes ( ) ; //copy camera properties to each eye
100+ //rotate each eye based on overlap percent, must do this after match eyes
101+ if ( _deviceDescriptor != null )
102+ {
103+ SetEyeRotation ( _deviceDescriptor . OverlapPercent , _deviceDescriptor . MonocularHorizontal ) ;
104+ SetEyeRoll ( _deviceDescriptor . LeftRoll , _deviceDescriptor . RightRoll ) ;
105+ }
106+ _initDisplayInterface = true ;
107+ }
94108 void UpdateViewMode ( )
95109 {
96110 if ( Time . realtimeSinceStartup < 100 || _previousViewMode != viewMode )
@@ -170,6 +184,8 @@ void Init()
170184
171185 //60 FPS whenever possible:
172186 Application . targetFrameRate = 60 ;
187+
188+ _initDisplayInterface = false ;
173189 }
174190
175191 /// <summary>
@@ -178,10 +194,10 @@ void Init()
178194 /// </summary>
179195 private void GetDeviceDescription ( )
180196 {
181- _deviceDescriptor = GetComponent < DisplayInterface > ( ) . GetDeviceDescription ( ) ;
182- Debug . Log ( _deviceDescriptor . ToString ( ) ) ;
197+ _deviceDescriptor = GetComponent < DisplayInterface > ( ) . GetDeviceDescription ( ) ;
183198 if ( _deviceDescriptor != null )
184199 {
200+ Debug . Log ( _deviceDescriptor . ToString ( ) ) ;
185201 switch ( _deviceDescriptor . DisplayMode )
186202 {
187203 case "full_screen" :
0 commit comments