{"record":{"id":"af2fddd66c62bb3d","repo":"Unity-Technologies/UnityCsReference","slug":"meta-file-not-found-metafilepath","errorCode":null,"errorMessage":"Meta file not found: {metaFilePath}","messagePattern":"Meta file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/InternalEditorUtility.bindings.cs","lineNumber":416,"sourceCode":"                GUIStyle labelStyle = new GUIStyle(EditorStyles.wordWrappedLabel);\n                labelStyle.padding = new RectOffset(8, 8, 6, 8);\n                Rect contentRect = GUILayoutUtility.GetRect(infoLabel, labelStyle);\n                EditorGUI.LabelField(contentRect, infoLabel, labelStyle);\n\n                // Button (align lower right)\n                Rect buttonRectPlaceholder = GUILayoutUtility.GetRect(1, kButtonHeight);\n                Rect buttonRect = new Rect(contentRect.xMax - buttonWidth - 8f, buttonRectPlaceholder.yMin, buttonWidth, kButtonHeight);\n                var buttonPressed = GUI.Button(buttonRect, buttonContent);\n                GUILayout.Space(6f);\n                return buttonPressed;\n            }\n        }\n\n        internal static void SetTextureReadable(string metaFilePath)\n        {\n            if (!File.Exists(metaFilePath))\n            {\n                throw new FileNotFoundException($\"Meta file not found: {metaFilePath}\");\n            }\n\n            // Read all lines from the meta file\n            string[] lines = File.ReadAllLines(metaFilePath, Encoding.UTF8);\n\n            // Find and modify the isReadable line\n            bool modified = false;\n            for (int i = 0; i < lines.Length; i++)\n            {\n                // Look for the isReadable property line\n                if (Regex.IsMatch(lines[i], @\"^\\s*isReadable:\\s*\\d+\\s*$\"))\n                {\n                    // Replace with isReadable: 1, preserving original indentation\n                    var match = Regex.Match(lines[i], @\"^(\\s*)isReadable:\\s*\\d+(\\s*)$\");\n                    if (match.Success)\n                    {\n                        lines[i] = $\"{match.Groups[1].Value}isReadable: 1{match.Groups[2].Value}\";\n                        modified = true;","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/InternalEditorUtility.bindings.cs#L398-L434","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the asset path resolves to an existing file and that AssetDatabase.ImportAsset has run so the .meta exists before calling SetTextureReadable.","Construct the meta path from a known-good absolute project path (Path.GetFullPath(assetPath) + '.meta') and check File.Exists yourself first.","Re-import the texture (AssetDatabase.ImportAsset) so Unity regenerates a missing .meta file, then retry."],"exampleFix":"// before\nInternalEditorUtility.SetTextureReadableByAssetPath(textureAssetPath);\n\n// after\nvar metaPath = textureAssetPath + \".meta\";\nif (!File.Exists(metaPath))\n    AssetDatabase.ImportAsset(textureAssetPath);\nInternalEditorUtility.SetTextureReadableByAssetPath(textureAssetPath);","handlingStrategy":"validation","validationCode":"string metaPath = textureAssetPath + \".meta\";\nif (!File.Exists(metaPath)) { AssetDatabase.ImportAsset(textureAssetPath); }\n// now safe to call SetTextureReadableByAssetPath","typeGuard":null,"tryCatchPattern":"try { SetTextureReadableByAssetPath(path); }\ncatch (FileNotFoundException ex) when (ex.FileName != null) { Debug.LogError($\"Missing meta: {ex.FileName}\"); AssetDatabase.ImportAsset(path); }","preventionTips":["Always import the asset before manipulating its meta file","Derive the meta path from a verified asset path","Re-import to regenerate a missing .meta"],"tags":["unity","editor","asset-database","filesystem","texture"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}