Skip to content

Commit df51161

Browse files
Antoine Lelievresebastienlagarde
andauthored
[HDRP] Fix material upgrader (#4821)
* Fix HDRP material upgrade failing when there is a texture inside the builtin resources assigned in the material * Updated changelog Co-authored-by: sebastienlagarde <[email protected]>
1 parent 30135ea commit df51161

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
259259
- Fixed an issue with resolution dependence for physically based depth of field.
260260
- Fixed the shader graph files that was still dirty after the first save (case 1342039).
261261
- Fixed cases in which object and camera motion vectors would cancel out, but didn't.
262+
- Fixed HDRP material upgrade failing when there is a texture inside the builtin resources assigned in the material (case 1339865).
262263

263264
### Changed
264265
- Changed Window/Render Pipeline/HD Render Pipeline Wizard to Window/Rendering/HDRP Wizard

com.unity.render-pipelines.high-definition/Editor/Core/TextureCombiner/TextureCombiner.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ public Texture2D Combine(string savePath)
246246
//cleanup "raw" textures
247247
foreach (KeyValuePair<Texture, Texture> prop in m_RawTextures)
248248
{
249-
if (AssetDatabase.Contains(prop.Value))
249+
if (prop.Key != prop.Value && AssetDatabase.Contains(prop.Value))
250250
AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(prop.Value));
251251
}
252252

@@ -262,13 +262,12 @@ private Texture GetRawTexture(Texture original, bool sRGBFallback = false)
262262
if (m_RawTextures == null) m_RawTextures = new Dictionary<Texture, Texture>();
263263
if (!m_RawTextures.ContainsKey(original))
264264
{
265-
if (AssetDatabase.Contains(original))
266-
{
267-
string path = AssetDatabase.GetAssetPath(original);
268-
string rawPath = "Assets/raw_" + Path.GetFileName(path);
269-
270-
AssetDatabase.CopyAsset(path, rawPath);
265+
string path = AssetDatabase.GetAssetPath(original);
266+
string rawPath = "Assets/raw_" + Path.GetFileName(path);
267+
bool isBuiltinResource = path.Contains("unity_builtin");
271268

269+
if (!isBuiltinResource && AssetDatabase.Contains(original) && AssetDatabase.CopyAsset(path, rawPath))
270+
{
272271
AssetDatabase.ImportAsset(rawPath);
273272

274273
TextureImporter rawImporter = (TextureImporter)AssetImporter.GetAtPath(rawPath);

0 commit comments

Comments
 (0)