Skip to content

Commit bd8038f

Browse files
[HDRP][LookDev] Ensure stylesheet are loaded before applying them on Domain Reload (#1985)
* Ensure stylesheet are loaded before applying them on Domain Reload * Added changelog description * Fix for upgrade package workflow Co-authored-by: sebastienlagarde <[email protected]>
1 parent c770bd8 commit bd8038f

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed

com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
@@ -694,14 +718,11 @@ void OnGUI()
694718
// rootVisualElement.styleSheets.Add(styleSheetLight);
695719
//}
696720
}
697-
else
698-
{
699-
//deal with missing style when domain reload...
700-
if (!rootVisualElement.styleSheets.Contains(styleSheet))
701-
rootVisualElement.styleSheets.Add(styleSheet);
702-
if (!EditorGUIUtility.isProSkin && !rootVisualElement.styleSheets.Contains(styleSheetLight))
703-
rootVisualElement.styleSheets.Add(styleSheetLight);
704-
}
721+
if(EditorApplication.isUpdating)
722+
return;
723+
724+
//deal with missing style on domain reload...
725+
ReloadStyleSheets();
705726

706727
OnUpdateRequestedInternal?.Invoke();
707728
}

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Changelog
1+
# Changelog
22
All notable changes to this package will be documented in this file.
33

44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
@@ -119,6 +119,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
119119
- Fixed rendergraph motion vector resolve.
120120
- Fixed the Ray-Tracing related Debug Display not working in render graph mode.
121121
- Fix nan in pbr sky
122+
- Fixed Light skin not properly applied on the LookDev when switching from Dark Skin (case 1278802)
122123

123124
### Changed
124125
- Preparation pass for RTSSShadows to be supported by render graph.

0 commit comments

Comments
 (0)