{"record":{"id":"2e4f8c51c273f513","repo":"EllanJiang/GameFramework","slug":"you-can-not-set-read-only-path-at-this-time","errorCode":null,"errorMessage":"You can not set read-only path at this time.","messagePattern":"You can not set read-only path at this time\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":866,"sourceCode":"            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>\n        /// <param name=\"readWritePath\">资源读写区路径。</param>\n        public void SetReadWritePath(string readWritePath)\n        {\n            if (string.IsNullOrEmpty(readWritePath))\n            {","sourceCodeStart":848,"sourceCodeEnd":884,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L848-L884","documentation":"SetReadOnlyPath throws this when m_RefuseSetFlag is true, meaning the ResourceManager has already finished initialization (Initialize/Preshutdown sequence) and configuration is locked. Path setters are only allowed during setup.","triggerScenarios":"Calling SetReadOnlyPath after initialization completes and m_RefuseSetFlag has been set by the framework's initialization flow.","commonSituations":"Deferred or late configuration (e.g. setting the path from an async callback after GameEntry initialized components), or calling SetReadOnlyPath again after resource system startup.","solutions":["Move SetReadOnlyPath earlier in startup, before ResourceManager initialization runs","Remove duplicate/late SetReadOnlyPath calls once the flag is set","Set the path in the Unity inspector (ResourceComponent.ReadOnlyPath) or via GameEntry before init"],"exampleFix":"// before\nasync void Start() { await LoadConfig(); resourceComponent.SetReadOnlyPath(cfg.Path); } // too late\n// after\nvoid Awake() { resourceComponent.SetReadOnlyPath(knownPath); } // before initialization","handlingStrategy":"validation","validationCode":"if (!resourceComponent.Initialized) resourceComponent.SetReadOnlyPath(path); else Log.Warning(\"Too late to set read-only path\");","typeGuard":null,"tryCatchPattern":"try { resourceComponent.SetReadOnlyPath(path); }\ncatch (GameFrameworkException) { Log.Error(\"Read-only path must be set before resource initialization completes.\"); }","preventionTips":["Configure ResourceManager exclusively in the bootstrap phase (Awake)","Never call path setters after GameEntry initialization","Centralize all resource config in one startup function"],"tags":["gameframework","unity","resource","initialization-order"],"backgroundTag":"invalid-state-transition","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"}