From 6f046bc3c4b43dbecffb35d53abf1c0e48973dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolaj=20Z=C3=B8llner?= Date: Wed, 9 Feb 2022 15:57:21 +0100 Subject: [PATCH 1/2] Added builtin resource reload check --- .../Runtime/Utilities/ResourceReloader.cs | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/com.unity.render-pipelines.core/Runtime/Utilities/ResourceReloader.cs b/com.unity.render-pipelines.core/Runtime/Utilities/ResourceReloader.cs index fba907fb29c..1467924a25c 100644 --- a/com.unity.render-pipelines.core/Runtime/Utilities/ResourceReloader.cs +++ b/com.unity.render-pipelines.core/Runtime/Utilities/ResourceReloader.cs @@ -190,19 +190,34 @@ static UnityEngine.Object Load(string path, Type type, bool builtin) // Else the path is good. Attempt loading resource if AssetDatabase available. UnityEngine.Object result; - if (builtin && type == typeof(Shader)) - { - result = Shader.Find(path); - } - else + try { - result = AssetDatabase.LoadAssetAtPath(path, type); + if (builtin && type == typeof(Shader)) + { + result = Shader.Find(path); + } + else + { + result = AssetDatabase.LoadAssetAtPath(path, type); - if (IsNull(result)) - result = Resources.GetBuiltinResource(type, path); + if (IsNull(result)) + result = Resources.GetBuiltinResource(type, path); - if (IsNull(result)) - result = AssetDatabase.GetBuiltinExtraResource(type, path); + if (IsNull(result)) + result = AssetDatabase.GetBuiltinExtraResource(type, path); + } + } + catch (Exception e) + { + //guid is not null as checked before unless this is builtin + if (!builtin) + { + var ex = new Exception($"Cannot load. Path {path} is correct but AssetDatabase cannot load now."); + ex.Data["InvalidImport"] = 1; + throw ex; + } + else + throw e; } if (IsNull(result)) From fbb5b819d8bb3172bab4df3da5e4b41fdc3df361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolaj=20Z=C3=B8llner?= Date: Wed, 9 Feb 2022 15:59:28 +0100 Subject: [PATCH 2/2] Updated changelog --- com.unity.render-pipelines.core/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.core/CHANGELOG.md b/com.unity.render-pipelines.core/CHANGELOG.md index 7a4f60d9722..c651dfc27c3 100644 --- a/com.unity.render-pipelines.core/CHANGELOG.md +++ b/com.unity.render-pipelines.core/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed the issue with the special Turkish i, when looking for the m_IsGlobal property in VolumeEditor. (case 1276892) - Fixed texture gather macros for GLCore and moved them from target 4.6 to target 4.5. - Fixed cubemap array macros for GLCore. +- Built-in resources will also throw invalid import if the ResourceReloader is unable to retrive the resource. ## [14.0.0] - 2021-11-17