{"record":{"id":"59caae84af6fee83","repo":"Unity-Technologies/UnityCsReference","slug":"could-not-find-editor-resource-assetpath","errorCode":null,"errorMessage":"Could not find editor resource ${assetPath}","messagePattern":"Could not find editor resource (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/EditorResources.cs","lineNumber":436,"sourceCode":"            if (File.Exists(path))\n                return path;\n            return new FileInfo(ExpandPath(path)).FullName;\n        }\n\n        // Checks if an editor resource asset path exists.\n        public static bool Exists(string path)\n        {\n            if (File.Exists(path))\n                return true;\n            return File.Exists(ExpandPath(path));\n        }\n\n        // Loads an editor resource asset.\n        public static T Load<T>(string assetPath, bool isRequired = true) where T : UnityEngine.Object\n        {\n            var obj = Load(assetPath, typeof(T));\n            if (!obj && isRequired)\n                throw new FileNotFoundException(\"Could not find editor resource \" + assetPath);\n            return obj as T;\n        }\n\n        // Returns a globally defined style element by name.\n        internal static StyleBlock GetStyle(string selectorName, params StyleState[] states) { return styleCatalog.GetStyle(selectorName, states); }\n        internal static StyleBlock GetStyle(int selectorKey, params StyleState[] states) { return styleCatalog.GetStyle(selectorKey, states); }\n\n        // Loads an USS asset into the global style catalog\n        internal static void LoadStyles(string ussPath)\n        {\n            styleCatalog.Load(ussPath);\n        }\n\n        // Creates a new style catalog from a set of USS assets.\n        internal static StyleCatalog LoadCatalog(string[] ussPaths)\n        {\n            var catalog = new StyleCatalog();\n            catalog.Load(ussPaths);","sourceCodeStart":418,"sourceCodeEnd":454,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/EditorResources.cs#L418-L454","documentation":"Thrown by EditorResources.Load<T> when the asset load returns a null/falsy object and isRequired is true (the default). It is a FileNotFoundException naming the assetPath. This is the 'hard-fail' contract for editor resources that the caller asserts must exist (styles, icons, defaults).","triggerScenarios":"Calling EditorResources.Load<T>(path) or Load<T>(path, isRequired:true) for a path that does not resolve through File.Exists, ExpandPath, or the asset bundle. Triggered by a typo, a renamed resource, or a missing package contribution.","commonSituations":"Custom editor extensions referencing a resource path that was moved in a Unity/package upgrade; package that forgot to ship an expected DefaultAsset; localized style paths differing across editor skins.","solutions":["Verify the exact assetPath against the package's shipped resources (case-sensitive on case-sensitive filesystems).","If the resource is optional, call Load<T>(path, isRequired:false) and handle null gracefully.","Use EditorResources.Exists(path) to probe before a required load.","Bundle the resource with your package and reference it via a PackageResource path."],"exampleFix":"// before\nvar icon = EditorResources.Load<Texture2D>(\"Icons/MyIcon.png\");\n\n// after\nif (EditorResources.Exists(\"Icons/MyIcon.png\"))\n    var icon = EditorResources.Load<Texture2D>(\"Icons/MyIcon.png\");\nelse\n    var icon = EditorResources.Load<Texture2D>(\"Icons/MyIcon.png\", isRequired:false);","handlingStrategy":"try-catch","validationCode":"if (!EditorResources.Exists(assetPath)) { if (!isRequired) return null; Debug.LogError($\"Missing editor resource: {assetPath}\"); }","typeGuard":null,"tryCatchPattern":"try { return EditorResources.Load<T>(assetPath, isRequired); } catch (FileNotFoundException) { return null; /* or fallback asset */ }","preventionTips":["Probe with EditorResources.Exists before a required load.","Use isRequired:false for optional resources and handle null.","Pin resource paths relative to your package so renames surface at build time."],"tags":["csharp","unity-editor","resources","file-not-found","packages"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}