{"record":{"id":"8b63a0a5c4703045","repo":"EllanJiang/GameFramework","slug":"you-must-set-read-write-path-before-add-load-resource-agent","errorCode":null,"errorMessage":"You must set read-write path before add load resource agent helper.","messagePattern":"You must set read-write path before add load resource agent helper\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":895,"sourceCode":"        /// <summary>\n        /// 设置资源读写区路径。\n        /// </summary>\n        /// <param name=\"readWritePath\">资源读写区路径。</param>\n        public void SetReadWritePath(string readWritePath)\n        {\n            if (string.IsNullOrEmpty(readWritePath))\n            {\n                throw new GameFrameworkException(\"Read-write path is invalid.\");\n            }\n\n            if (m_RefuseSetFlag)\n            {\n                throw new GameFrameworkException(\"You can not set read-write path at this time.\");\n            }\n\n            if (m_ResourceLoader.TotalAgentCount > 0)\n            {\n                throw new GameFrameworkException(\"You must set read-write path before add load resource agent helper.\");\n            }\n\n            m_ReadWritePath = readWritePath;\n        }\n\n        /// <summary>\n        /// 设置资源模式。\n        /// </summary>\n        /// <param name=\"resourceMode\">资源模式。</param>\n        public void SetResourceMode(ResourceMode resourceMode)\n        {\n            if (resourceMode == ResourceMode.Unspecified)\n            {\n                throw new GameFrameworkException(\"Resource mode is invalid.\");\n            }\n\n            if (m_RefuseSetFlag)\n            {","sourceCodeStart":877,"sourceCodeEnd":913,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L877-L913","documentation":"Thrown by ResourceManager.SetReadWritePath when the resource loader already has agents added (TotalAgentCount > 0). The read-write path feeds agent helpers, so changing it after agents exist would leave them with stale paths; set the path before AddLoadResourceAgentHelper is used.","triggerScenarios":"Calling SetReadWritePath after AddLoadResourceAgentHelper or any flow that registers resource agents.","commonSituations":"Reordering mistakes in startup code, or attempting to change where resources are stored while the resource system is live.","solutions":["Call SetReadWritePath before adding any resource agent helpers","Reorder the initialization sequence: paths, mode, then agent helpers","Restart/reinitialize the module if the path genuinely must change"],"exampleFix":"// before\nloader.AddLoadResourceAgentHelper(helper);\nresourceComponent.SetReadWritePath(path);\n// after\nresourceComponent.SetReadWritePath(path);\nloader.AddLoadResourceAgentHelper(helper);","handlingStrategy":"validation","validationCode":"if (resourceComponent.ResourceLoaderTotalAgentCount == 0) resourceComponent.SetReadWritePath(path);","typeGuard":null,"tryCatchPattern":"try { resourceComponent.SetReadWritePath(path); }\ncatch (GameFrameworkException) { Log.Error(\"Set read-write path before adding load resource agent helpers.\"); }","preventionTips":["Configure paths before any AddLoadResourceAgentHelper call","Keep resource setup in one ordered function","Do not attempt runtime path reconfiguration"],"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"}