Unity-Technologies/UnityCsReference · error · InvalidOperationException

Could not find isReadable property in the meta file

Error message

Could not find isReadable property in the meta file

What it means

Thrown after SetTextureReadable reads every line of a texture .meta file and finds no line matching the isReadable property regex (a 'isReadable: <digit>' line). It means the meta file exists but its contents are not the expected Unity meta format, so the property cannot be located and rewritten.

Source

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

            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;
                        break;
                    }
                }
            }

            if (!modified)
            {
                throw new InvalidOperationException("Could not find isReadable property in the meta file");
            }

            // Write back to file
            File.WriteAllLines(metaFilePath, lines, Encoding.UTF8);
        }

        internal static void SetTextureReadableByAssetPath(string textureAssetPath)
        {
            string metaFilePath = textureAssetPath + ".meta";
            SetTextureReadable(metaFilePath);
            AssetDatabase.ImportAsset(textureAssetPath);
        }

        [FreeFunction("InternalEditorUtilityBindings::GetEditorAssemblyPath")]
        public extern static string GetEditorAssemblyPath();

        [FreeFunction("InternalEditorUtilityBindings::GetEngineAssemblyPath")]
        public extern static string GetEngineAssemblyPath();

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. Confirm the meta file belongs to an actual texture asset and not another asset type.
  2. Open the meta file and check that a line like 'isReadable: 0' exists; if missing or malformed, delete the .meta and let Unity re-import the texture to regenerate it.
  3. Upgrade or repair the meta file by forcing a reimport: AssetDatabase.ImportAsset with ImportAssetOptions.ForceUpdate.

Example fix

// before
InternalEditorUtility.SetTextureReadable(metaFilePath);

// after
var lines = File.ReadAllLines(metaFilePath);
if (!lines.Any(l => Regex.IsMatch(l, @"^\s*isReadable:\s*\d+\s*$")))
    AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate);
InternalEditorUtility.SetTextureReadable(metaFilePath);
Defensive patterns

Strategy: validation

Validate before calling

var lines = File.ReadAllLines(metaFilePath);
bool hasReadable = System.Array.FindIndex(lines, l => System.Text.RegularExpressions.Regex.IsMatch(l, @"^\s*isReadable:\s*\d+\s*$")) >= 0;
if (!hasReadable) { AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); }

Try / catch

try { SetTextureReadable(metaFilePath); }
catch (InvalidOperationException) { AssetDatabase.ImportAsset(assetPath, ImportAssetOptions.ForceUpdate); SetTextureReadable(metaFilePath); }

Prevention

When it happens

Trigger: Calling SetTextureReadable on a meta file that is empty, truncated, hand-edited, from a very old Unity version that used a different textureImporterSettings layout, or that belongs to a non-texture asset (the isReadable setting is specific to TextureImporter).

Common situations: Passing the meta file of a non-texture asset (material, script, audio) which has no isReadable field. Corrupted or partially-written meta files from a crash or a bad VCS merge. Meta files produced by a much newer/older Unity major version with a different importer schema.

Related errors


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