diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 7496c268d5b..d930b8f6b88 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -61,6 +61,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Moved AMD FidelityFX shaders to core - Improved sampling of overlapping point/area lights in path-traced volumetric scattering (case 1358777). - Path-traced volumetric scattering now takes fog color into account, adding scattered contribution on top of the non-scattered result (cases 1346105, 1358783). +- MaterialReimporter.ReimportAllMaterials and MaterialReimporter.ReimportAllHDShaderGraphs now batch the asset database changes to improve performance. - Fixed minor readability issues in the ray tracing code. ## [12.0.0] - 2021-01-11 diff --git a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs index a2ccc6dc147..04a80eafc08 100644 --- a/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs @@ -75,13 +75,25 @@ static internal void ReimportAllMaterials() int materialIdx = 0; int totalMaterials = distinctGuids.Count(); - foreach (var asset in distinctGuids) + + try + { + AssetDatabase.StartAssetEditing(); + + foreach (var asset in distinctGuids) + { + materialIdx++; + var path = AssetDatabase.GUIDToAssetPath(asset); + EditorUtility.DisplayProgressBar("Material Upgrader re-import", string.Format("({0} of {1}) {2}", materialIdx, totalMaterials, path), (float)materialIdx / (float)totalMaterials); + AssetDatabase.ImportAsset(path); + } + } + finally { - materialIdx++; - var path = AssetDatabase.GUIDToAssetPath(asset); - EditorUtility.DisplayProgressBar("Material Upgrader re-import", string.Format("({0} of {1}) {2}", materialIdx, totalMaterials, path), (float)materialIdx / (float)totalMaterials); - AssetDatabase.ImportAsset(path); + // Ensure the AssetDatabase knows we're finished editing + AssetDatabase.StopAssetEditing(); } + UnityEditor.EditorUtility.ClearProgressBar(); MaterialPostprocessor.s_NeedsSavingAssets = true; @@ -95,17 +107,29 @@ static internal void ReimportAllHDShaderGraphs() int shaderIdx = 0; int totalShaders = distinctGuids.Count(); - foreach (var asset in distinctGuids) + + try { - shaderIdx++; - var path = AssetDatabase.GUIDToAssetPath(asset); - EditorUtility.DisplayProgressBar("HD ShaderGraph Upgrader re-import", string.Format("({0} of {1}) {2}", shaderIdx, totalShaders, path), (float)shaderIdx / (float)totalShaders); + AssetDatabase.StartAssetEditing(); - if (CheckHDShaderGraphVersionsForUpgrade(path)) + foreach (var asset in distinctGuids) { - AssetDatabase.ImportAsset(path); + shaderIdx++; + var path = AssetDatabase.GUIDToAssetPath(asset); + EditorUtility.DisplayProgressBar("HD ShaderGraph Upgrader re-import", string.Format("({0} of {1}) {2}", shaderIdx, totalShaders, path), (float)shaderIdx / (float)totalShaders); + + if (CheckHDShaderGraphVersionsForUpgrade(path)) + { + AssetDatabase.ImportAsset(path); + } } } + finally + { + // Ensure the AssetDatabase knows we're finished editing + AssetDatabase.StopAssetEditing(); + } + UnityEditor.EditorUtility.ClearProgressBar(); MaterialPostprocessor.s_NeedsSavingAssets = true; diff --git a/com.unity.render-pipelines.universal/CHANGELOG.md b/com.unity.render-pipelines.universal/CHANGELOG.md index 0fe8f1f16f9..31adbcbfeff 100644 --- a/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/com.unity.render-pipelines.universal/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Removed experimental tile deferred code. - VFX: New shadergraph support directly on Universal target. +- MaterialReimporter.ReimportAllMaterials now batches the asset database changes to improve performance. - URP will no longer render via an intermediate texture unless actively required by a Renderer Feature. See the upgrade guide for compatibility options and how assets are upgraded. ### Fixed diff --git a/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs b/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs index d4ddaffadb3..aeda8e6c365 100644 --- a/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs +++ b/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs @@ -33,13 +33,25 @@ static void ReimportAllMaterials() int materialIdx = 0; int totalMaterials = distinctGuids.Count(); - foreach (var asset in distinctGuids) + + try { - materialIdx++; - var path = AssetDatabase.GUIDToAssetPath(asset); - EditorUtility.DisplayProgressBar("Material Upgrader re-import", string.Format("({0} of {1}) {2}", materialIdx, totalMaterials, path), (float)materialIdx / (float)totalMaterials); - AssetDatabase.ImportAsset(path); + AssetDatabase.StartAssetEditing(); + + foreach (var asset in distinctGuids) + { + materialIdx++; + var path = AssetDatabase.GUIDToAssetPath(asset); + EditorUtility.DisplayProgressBar("Material Upgrader re-import", string.Format("({0} of {1}) {2}", materialIdx, totalMaterials, path), (float)materialIdx / (float)totalMaterials); + AssetDatabase.ImportAsset(path); + } } + finally + { + // Ensure the AssetDatabase knows we're finished editing + AssetDatabase.StopAssetEditing(); + } + EditorUtility.ClearProgressBar(); MaterialPostprocessor.s_NeedsSavingAssets = true;