Skip to content

Commit 15302a0

Browse files
jenniferd-unitysebastienlagarde
authored andcommitted
[HDRP][LookDev] Ensure stylesheet are loaded before applying them on Domain Reload (#1985)
1 parent 951f12d commit 15302a0

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
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.
@@ -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.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1616
- Fixed issue with volume manager trying to access a null volume.
1717
- Fixed an issue that caused a null reference when deleting camera component in a prefab. (case 1244430)
1818
- Fixed nan in pbr sky
19+
- Fixed Light skin not properly applied on the LookDev when switching from Dark Skin (case 1278802)
1920

2021
## [7.5.1] - 2020-09-02
2122

0 commit comments

Comments
 (0)