Unity-Technologies/UnityCsReference · error · FileNotFoundException

Meta file not found: {metaFilePath}

Error message

Meta file not found: {metaFilePath}

What it means

Thrown by InternalEditorUtility.SetTextureReadable when the .meta file path passed in does not exist on disk. The method is an internal editor utility that rewrites a texture's meta file to flip isReadable to 1, and it refuses to operate on a non-existent file. It is typically reached via SetTextureReadableByAssetPath which appends '.meta' to an asset path.

Source

Thrown at Editor/Mono/InternalEditorUtility.bindings.cs:416

                GUIStyle labelStyle = new GUIStyle(EditorStyles.wordWrappedLabel);
                labelStyle.padding = new RectOffset(8, 8, 6, 8);
                Rect contentRect = GUILayoutUtility.GetRect(infoLabel, labelStyle);
                EditorGUI.LabelField(contentRect, infoLabel, labelStyle);

                // Button (align lower right)
                Rect buttonRectPlaceholder = GUILayoutUtility.GetRect(1, kButtonHeight);
                Rect buttonRect = new Rect(contentRect.xMax - buttonWidth - 8f, buttonRectPlaceholder.yMin, buttonWidth, kButtonHeight);
                var buttonPressed = GUI.Button(buttonRect, buttonContent);
                GUILayout.Space(6f);
                return buttonPressed;
            }
        }

        internal static void SetTextureReadable(string metaFilePath)
        {
            if (!File.Exists(metaFilePath))
            {
                throw new FileNotFoundException($"Meta file not found: {metaFilePath}");
            }

            // Read all lines from the meta file
            string[] lines = File.ReadAllLines(metaFilePath, Encoding.UTF8);

            // Find and modify the isReadable line
            bool modified = false;
            for (int i = 0; i < lines.Length; i++)
            {
                // Look for the isReadable property line
                if (Regex.IsMatch(lines[i], @"^\s*isReadable:\s*\d+\s*$"))
                {
                    // Replace with isReadable: 1, preserving original indentation
                    var match = Regex.Match(lines[i], @"^(\s*)isReadable:\s*\d+(\s*)$");
                    if (match.Success)
                    {
                        lines[i] = $"{match.Groups[1].Value}isReadable: 1{match.Groups[2].Value}";
                        modified = true;

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Verify the asset path resolves to an existing file and that AssetDatabase.ImportAsset has run so the .meta exists before calling SetTextureReadable.
  2. Construct the meta path from a known-good absolute project path (Path.GetFullPath(assetPath) + '.meta') and check File.Exists yourself first.
  3. Re-import the texture (AssetDatabase.ImportAsset) so Unity regenerates a missing .meta file, then retry.

Example fix

// before
InternalEditorUtility.SetTextureReadableByAssetPath(textureAssetPath);

// after
var metaPath = textureAssetPath + ".meta";
if (!File.Exists(metaPath))
    AssetDatabase.ImportAsset(textureAssetPath);
InternalEditorUtility.SetTextureReadableByAssetPath(textureAssetPath);
Defensive patterns

Strategy: validation

Validate before calling

string metaPath = textureAssetPath + ".meta";
if (!File.Exists(metaPath)) { AssetDatabase.ImportAsset(textureAssetPath); }
// now safe to call SetTextureReadableByAssetPath

Try / catch

try { SetTextureReadableByAssetPath(path); }
catch (FileNotFoundException ex) when (ex.FileName != null) { Debug.LogError($"Missing meta: {ex.FileName}"); AssetDatabase.ImportAsset(path); }

Prevention

When it happens

Trigger: Calling SetTextureReadable(metaFilePath) or SetTextureReadableByAssetPath(textureAssetPath) where the resolved meta file path is wrong — e.g. the asset path does not have an importable .meta sibling, the path is relative to the wrong root, or the asset has not yet been imported by the AssetDatabase.

Common situations: Editor tooling that manipulates texture read/write settings programmatically and passes a path from AssetDatabase that is stale, uses backslashes on a case-sensitive filesystem, or runs before the meta file is generated. Also when an asset was deleted between resolving its path and calling the utility.

Related errors


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