Unity-Technologies/UnityCsReference · error · FileNotFoundException

Could not find editor resource ${assetPath}

Error message

Could not find editor resource ${assetPath}

What it means

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).

Source

Thrown at Editor/Mono/EditorResources.cs:436

            if (File.Exists(path))
                return path;
            return new FileInfo(ExpandPath(path)).FullName;
        }

        // Checks if an editor resource asset path exists.
        public static bool Exists(string path)
        {
            if (File.Exists(path))
                return true;
            return File.Exists(ExpandPath(path));
        }

        // Loads an editor resource asset.
        public static T Load<T>(string assetPath, bool isRequired = true) where T : UnityEngine.Object
        {
            var obj = Load(assetPath, typeof(T));
            if (!obj && isRequired)
                throw new FileNotFoundException("Could not find editor resource " + assetPath);
            return obj as T;
        }

        // Returns a globally defined style element by name.
        internal static StyleBlock GetStyle(string selectorName, params StyleState[] states) { return styleCatalog.GetStyle(selectorName, states); }
        internal static StyleBlock GetStyle(int selectorKey, params StyleState[] states) { return styleCatalog.GetStyle(selectorKey, states); }

        // Loads an USS asset into the global style catalog
        internal static void LoadStyles(string ussPath)
        {
            styleCatalog.Load(ussPath);
        }

        // Creates a new style catalog from a set of USS assets.
        internal static StyleCatalog LoadCatalog(string[] ussPaths)
        {
            var catalog = new StyleCatalog();
            catalog.Load(ussPaths);

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Verify the exact assetPath against the package's shipped resources (case-sensitive on case-sensitive filesystems).
  2. If the resource is optional, call Load<T>(path, isRequired:false) and handle null gracefully.
  3. Use EditorResources.Exists(path) to probe before a required load.
  4. Bundle the resource with your package and reference it via a PackageResource path.

Example fix

// before
var icon = EditorResources.Load<Texture2D>("Icons/MyIcon.png");

// after
if (EditorResources.Exists("Icons/MyIcon.png"))
    var icon = EditorResources.Load<Texture2D>("Icons/MyIcon.png");
else
    var icon = EditorResources.Load<Texture2D>("Icons/MyIcon.png", isRequired:false);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!EditorResources.Exists(assetPath)) { if (!isRequired) return null; Debug.LogError($"Missing editor resource: {assetPath}"); }

Try / catch

try { return EditorResources.Load<T>(assetPath, isRequired); } catch (FileNotFoundException) { return null; /* or fallback asset */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/59caae84af6fee83. Report an issue: GitHub.