@@ -216,24 +216,48 @@ event Action IViewDisplayer.OnUpdateRequested
216216 StyleSheet styleSheet = null ;
217217 StyleSheet styleSheetLight = null ;
218218
219- void OnEnable ( )
219+ void ReloadStyleSheets ( )
220220 {
221- //Stylesheet
222- // Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692).
223- // In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets.
224- // Waiting for filter on stylesheet (case 1228706) to remove last error.
225- if ( styleSheet == null || styleSheet . Equals ( null ) )
221+ if ( styleSheet == null || styleSheet . Equals ( null ) )
226222 {
227223 styleSheet = AssetDatabase . LoadAssetAtPath < StyleSheet > ( Style . k_uss ) ;
228- if ( styleSheet != null && ! styleSheet . Equals ( null ) )
229- rootVisualElement . styleSheets . Add ( styleSheet ) ;
224+ if ( styleSheet == null || styleSheet . Equals ( null ) )
225+ {
226+ //Debug.LogWarning("[LookDev] Could not load Stylesheet.");
227+ return ;
228+ }
230229 }
231- if ( ! EditorGUIUtility . isProSkin && styleSheetLight != null && ! styleSheetLight . Equals ( null ) )
230+
231+ if ( ! rootVisualElement . styleSheets . Contains ( styleSheet ) )
232+ rootVisualElement . styleSheets . Add ( styleSheet ) ;
233+
234+ //Additively load Light Skin
235+ if ( ! EditorGUIUtility . isProSkin )
232236 {
233- styleSheetLight = AssetDatabase . LoadAssetAtPath < StyleSheet > ( Style . k_uss_personal_overload ) ;
234- if ( styleSheetLight != null && ! styleSheetLight . Equals ( null ) )
237+ if ( styleSheetLight == null || styleSheetLight . Equals ( null ) )
238+ {
239+ styleSheetLight = AssetDatabase . LoadAssetAtPath < StyleSheet > ( Style . k_uss_personal_overload ) ;
240+ if ( styleSheetLight == null || styleSheetLight . Equals ( null ) )
241+ {
242+ //Debug.LogWarning("[LookDev] Could not load Light skin.");
243+ return ;
244+ }
245+ }
246+
247+ if ( ! rootVisualElement . styleSheets . Contains ( styleSheetLight ) )
235248 rootVisualElement . styleSheets . Add ( styleSheetLight ) ;
236249 }
250+ }
251+
252+ void OnEnable ( )
253+ {
254+ //Stylesheet
255+ // Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692).
256+ // In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets.
257+ // Waiting for filter on stylesheet (case 1228706) to remove last error.
258+ // On Editor Skin change, OnEnable is called and stylesheets need to be reloaded (case 1278802).
259+ if ( EditorApplication . isUpdating )
260+ ReloadStyleSheets ( ) ;
237261
238262 //Call the open function to configure LookDev
239263 // in case the window where open when last editor session finished.
@@ -681,14 +705,11 @@ void OnGUI()
681705 // rootVisualElement.styleSheets.Add(styleSheetLight);
682706 //}
683707 }
684- else
685- {
686- //deal with missing style when domain reload...
687- if ( ! rootVisualElement . styleSheets . Contains ( styleSheet ) )
688- rootVisualElement . styleSheets . Add ( styleSheet ) ;
689- if ( ! EditorGUIUtility . isProSkin && ! rootVisualElement . styleSheets . Contains ( styleSheetLight ) )
690- rootVisualElement . styleSheets . Add ( styleSheetLight ) ;
691- }
708+ if ( EditorApplication . isUpdating )
709+ return ;
710+
711+ //deal with missing style on domain reload...
712+ ReloadStyleSheets ( ) ;
692713
693714 // [case 1245086] Guard in case the SRP asset is set to null (or to a not supported SRP) when the lookdev window is already open
694715 // Note: After an editor reload, we might get a null OnUpdateRequestedInternal and null SRP for a couple of frames, hence the check.
0 commit comments