{"record":{"id":"aa97582ed5561544","repo":"EllanJiang/GameFramework","slug":"read-only-path-is-invalid-resourcemanager-resourceiniter","errorCode":null,"errorMessage":"Read-only path is invalid.","messagePattern":"Read-only path is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"critical","filePath":"GameFramework/Resource/ResourceManager.ResourceIniter.cs","lineNumber":61,"sourceCode":"            public void Shutdown()\n            {\n            }\n\n            /// <summary>\n            /// 初始化资源。\n            /// </summary>\n            public void InitResources(string currentVariant)\n            {\n                m_CurrentVariant = currentVariant;\n\n                if (m_ResourceManager.m_ResourceHelper == null)\n                {\n                    throw new GameFrameworkException(\"Resource helper is invalid.\");\n                }\n\n                if (string.IsNullOrEmpty(m_ResourceManager.m_ReadOnlyPath))\n                {\n                    throw new GameFrameworkException(\"Read-only path is invalid.\");\n                }\n\n                m_ResourceManager.m_ResourceHelper.LoadBytes(Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_ReadOnlyPath, RemoteVersionListFileName)), new LoadBytesCallbacks(OnLoadPackageVersionListSuccess, OnLoadPackageVersionListFailure), null);\n            }\n\n            private void OnLoadPackageVersionListSuccess(string fileUri, byte[] bytes, float duration, object userData)\n            {\n                MemoryStream memoryStream = null;\n                try\n                {\n                    memoryStream = new MemoryStream(bytes, false);\n                    PackageVersionList versionList = m_ResourceManager.m_PackageVersionListSerializer.Deserialize(memoryStream);\n                    if (!versionList.IsValid)\n                    {\n                        throw new GameFrameworkException(\"Deserialize package version list failure.\");\n                    }\n\n                    PackageVersionList.Asset[] assets = versionList.GetAssets();","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceIniter.cs#L43-L79","documentation":"Thrown by ResourceManager.ResourceIniter.InitResources when the resource system's read-only path is null or empty. The read-only path is where built-in (packaged) resources and the remote version list live, so initialization cannot proceed without it. The library fails fast before attempting to load the package version list file.","triggerScenarios":"Calling ResourceManager.InitResources (via ResourceComponent) before m_ReadOnlyPath has been set, or after it was set to string.Empty.","commonSituations":"Forgot to set the read-only path in the Unity ResourceComponent inspector; a build script cleared the path; running on a platform where Application.persistentDataPath/streamingAssets setup code was skipped.","solutions":["Set the read-only path before initializing: resourceComponent.ReadOnlyPath = Application.dataPath (or the packaged resource directory), then call InitResources.","Verify the ResourceComponent Inspector fields (Read-Only Path / Read-Write Path) are filled in the scene.","Check platform-specific bootstrap code that assigns m_ReadOnlyPath actually runs on the current target."],"exampleFix":"// before\nresourceComponent.InitResources(); // m_ReadOnlyPath never set\n// after\nresourceComponent.ReadOnlyPath = System.IO.Path.Combine(Application.streamingAssetsPath, \"GameFramework\");\nresourceComponent.InitResources();","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(resourceComponent.ReadOnlyPath)) throw new InvalidOperationException(\"Set ReadOnlyPath before InitResources.\");","typeGuard":"bool ReadOnlyPathValid => !string.IsNullOrEmpty(resourceComponent.ReadOnlyPath);","tryCatchPattern":null,"preventionTips":["Always assign ReadOnlyPath in a bootstrap scene before any InitResources call.","Add a startup assertion logging both ReadOnlyPath and ReadWritePath.","Keep path assignment platform-specific code in one place to avoid skipped branches."],"tags":["resource","initialization","gameframework","config"],"backgroundTag":"missing-required-config","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}