Skip to content

[HDRP][LookDev] Ensure stylesheet are loaded before applying them on Domain Reload #1985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 40 additions & 19 deletions com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,24 +216,48 @@ event Action IViewDisplayer.OnUpdateRequested
StyleSheet styleSheet = null;
StyleSheet styleSheetLight = null;

void OnEnable()
void ReloadStyleSheets()
{
//Stylesheet
// Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692).
// In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets.
// Waiting for filter on stylesheet (case 1228706) to remove last error.
if (styleSheet == null || styleSheet.Equals(null))
if(styleSheet == null || styleSheet.Equals(null))
{
styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>(Style.k_uss);
if (styleSheet != null && !styleSheet.Equals(null))
rootVisualElement.styleSheets.Add(styleSheet);
if(styleSheet == null || styleSheet.Equals(null))
{
//Debug.LogWarning("[LookDev] Could not load Stylesheet.");
return;
}
}
if (!EditorGUIUtility.isProSkin && styleSheetLight != null && !styleSheetLight.Equals(null))

if(!rootVisualElement.styleSheets.Contains(styleSheet))
rootVisualElement.styleSheets.Add(styleSheet);

//Additively load Light Skin
if(!EditorGUIUtility.isProSkin)
{
styleSheetLight = AssetDatabase.LoadAssetAtPath<StyleSheet>(Style.k_uss_personal_overload);
if (styleSheetLight != null && !styleSheetLight.Equals(null))
if(styleSheetLight == null || styleSheetLight.Equals(null))
{
styleSheetLight = AssetDatabase.LoadAssetAtPath<StyleSheet>(Style.k_uss_personal_overload);
if(styleSheetLight == null || styleSheetLight.Equals(null))
{
//Debug.LogWarning("[LookDev] Could not load Light skin.");
return;
}
}

if(!rootVisualElement.styleSheets.Contains(styleSheetLight))
rootVisualElement.styleSheets.Add(styleSheetLight);
}
}

void OnEnable()
{
//Stylesheet
// Try to load stylesheet. Timing can be odd while upgrading packages (case 1219692).
// In this case, it will be fixed in OnGUI. Though it can spawn error while reimporting assets.
// Waiting for filter on stylesheet (case 1228706) to remove last error.
// On Editor Skin change, OnEnable is called and stylesheets need to be reloaded (case 1278802).
if(EditorApplication.isUpdating)
ReloadStyleSheets();

//Call the open function to configure LookDev
// in case the window where open when last editor session finished.
Expand Down Expand Up @@ -694,14 +718,11 @@ void OnGUI()
// rootVisualElement.styleSheets.Add(styleSheetLight);
//}
}
else
{
//deal with missing style when domain reload...
if (!rootVisualElement.styleSheets.Contains(styleSheet))
rootVisualElement.styleSheets.Add(styleSheet);
if (!EditorGUIUtility.isProSkin && !rootVisualElement.styleSheets.Contains(styleSheetLight))
rootVisualElement.styleSheets.Add(styleSheetLight);
}
if(EditorApplication.isUpdating)
return;

//deal with missing style on domain reload...
ReloadStyleSheets();

OnUpdateRequestedInternal?.Invoke();
}
Expand Down
3 changes: 2 additions & 1 deletion com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Changelog
# Changelog
All notable changes to this package will be documented in this file.

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

### Changed
- Preparation pass for RTSSShadows to be supported by render graph.
Expand Down