{"record":{"id":"fe71987c3687d486","repo":"EllanJiang/GameFramework","slug":"read-only-path-is-invalid-resourcemanager","errorCode":null,"errorMessage":"Read-only path is invalid.","messagePattern":"Read-only path is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":861,"sourceCode":"            {\n                m_ResourceInfos.Clear();\n                m_ResourceInfos = null;\n            }\n\n            m_ReadOnlyFileSystems.Clear();\n            m_ReadWriteFileSystems.Clear();\n            m_ResourceGroups.Clear();\n        }\n\n        /// <summary>\n        /// 设置资源只读区路径。\n        /// </summary>\n        /// <param name=\"readOnlyPath\">资源只读区路径。</param>\n        public void SetReadOnlyPath(string readOnlyPath)\n        {\n            if (string.IsNullOrEmpty(readOnlyPath))\n            {\n                throw new GameFrameworkException(\"Read-only path is invalid.\");\n            }\n\n            if (m_RefuseSetFlag)\n            {\n                throw new GameFrameworkException(\"You can not set read-only path at this time.\");\n            }\n\n            if (m_ResourceLoader.TotalAgentCount > 0)\n            {\n                throw new GameFrameworkException(\"You must set read-only path before add load resource agent helper.\");\n            }\n\n            m_ReadOnlyPath = readOnlyPath;\n        }\n\n        /// <summary>\n        /// 设置资源读写区路径。\n        /// </summary>","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L843-L879","documentation":"ResourceManager.SetReadOnlyPath throws GameFrameworkException when the readOnlyPath argument is null or an empty string. The read-only path is where built-in resources shipped with the app live; the framework refuses to configure it with an invalid value. This is a fail-fast argument validation.","triggerScenarios":"Calling resourceComponent.SetReadOnlyPath(null) or resourceComponent.SetReadOnlyPath(\"\") before any resource agents are added.","commonSituations":"Reading the path from a config file, PlayerPrefs, or Application.streamingAssetsPath-like source that resolves to null/empty on the target platform (e.g. a missing config key or a platform where the value is not populated).","solutions":["Pass a valid non-empty absolute or relative path, e.g. Application.dataPath-based persistent or streaming path","Check the config source that supplies the path and fix the missing/empty value","Guard the call with string.IsNullOrEmpty before invoking SetReadOnlyPath"],"exampleFix":"// before\nresourceComponent.SetReadOnlyPath(config.ReadOnlyPath); // config.ReadOnlyPath was null\n// after\nif (!string.IsNullOrEmpty(config.ReadOnlyPath))\n{\n    resourceComponent.SetReadOnlyPath(config.ReadOnlyPath);\n}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(readOnlyPath)) throw new ArgumentException(\"readOnlyPath must be a non-empty string\");\nresourceComponent.SetReadOnlyPath(readOnlyPath);","typeGuard":"bool IsValidPath(string p) => !string.IsNullOrEmpty(p);","tryCatchPattern":"try { resourceComponent.SetReadOnlyPath(path); }\ncatch (GameFrameworkException ex) { Log.Error(\"SetReadOnlyPath failed: {0}\", ex.Message); }","preventionTips":["Validate all path config values before configuring components","Fail fast at startup when a required path is empty","Log the config source when a path is missing"],"tags":["gameframework","unity","resource","argument-validation"],"backgroundTag":"empty-required-field","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}