diff --git a/Assets/Scripts/Core/Fsr3UpscalerShaders.cs b/Assets/Scripts/Core/Fsr3UpscalerShaders.cs index 154fbc4..8b67a27 100644 --- a/Assets/Scripts/Core/Fsr3UpscalerShaders.cs +++ b/Assets/Scripts/Core/Fsr3UpscalerShaders.cs @@ -72,11 +72,11 @@ namespace FidelityFX private static ComputeShader FindComputeShader(string name) { - string[] assets = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}"); - if (assets == null || assets.Length == 0) + string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:ComputeShader {name}"); + if (assetGuids == null || assetGuids.Length == 0) return null; - string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assets[0]); + string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]); return UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath); } #endif diff --git a/Assets/Scripts/Fsr3UpscalerImageEffect.cs b/Assets/Scripts/Fsr3UpscalerImageEffect.cs index 5554dec..0270091 100644 --- a/Assets/Scripts/Fsr3UpscalerImageEffect.cs +++ b/Assets/Scripts/Fsr3UpscalerImageEffect.cs @@ -146,6 +146,13 @@ namespace FidelityFX enabled = false; return; } + + if (shaders == null) + { + Debug.LogError($"FSR3 Upscaler shaders are not assigned! Please ensure an {nameof(Fsr3UpscalerShaders)} asset is assigned to the Shaders property of this component."); + enabled = false; + return; + } if (_maxRenderSize.x == 0 || _maxRenderSize.y == 0) { @@ -459,5 +466,20 @@ namespace FidelityFX return _maxRenderSize; } + + #if UNITY_EDITOR + private void Reset() + { + if (shaders != null) + return; + + string[] assetGuids = UnityEditor.AssetDatabase.FindAssets($"t:{nameof(Fsr3UpscalerShaders)}"); + if (assetGuids == null || assetGuids.Length == 0) + return; + + string assetPath = UnityEditor.AssetDatabase.GUIDToAssetPath(assetGuids[0]); + shaders = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath); + } + #endif } }