{"record":{"id":"5aac96a2e4535f13","repo":"EllanJiang/GameFramework","slug":"you-can-not-set-resource-mode-at-this-time","errorCode":null,"errorMessage":"You can not set resource mode at this time.","messagePattern":"You can not set resource mode at this time\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":914,"sourceCode":"            }\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            {\n                throw new GameFrameworkException(\"You can not set resource mode at this time.\");\n            }\n\n            if (m_ResourceMode == ResourceMode.Unspecified)\n            {\n                m_ResourceMode = resourceMode;\n\n                if (m_ResourceMode == ResourceMode.Package)\n                {\n                    m_PackageVersionListSerializer = new PackageVersionListSerializer();\n\n                    m_ResourceIniter = new ResourceIniter(this);\n                    m_ResourceIniter.ResourceInitComplete += OnIniterResourceInitComplete;\n                }\n                else if (m_ResourceMode == ResourceMode.Updatable || m_ResourceMode == ResourceMode.UpdatableWhilePlaying)\n                {\n                    m_UpdatableVersionListSerializer = new UpdatableVersionListSerializer();\n                    m_ReadOnlyVersionListSerializer = new ReadOnlyVersionListSerializer();\n                    m_ReadWriteVersionListSerializer = new ReadWriteVersionListSerializer();","sourceCodeStart":896,"sourceCodeEnd":932,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L896-L932","documentation":"Thrown by ResourceManager.SetResourceMode when m_RefuseSetFlag is set, meaning the resource system has already initialized and locked its configuration. The resource mode (Package vs Updatable) determines the whole loading pipeline and cannot change after startup; set it before initialization.","triggerScenarios":"Calling SetResourceMode after ResourceManager initialization completes and locks the setters.","commonSituations":"Switching resource mode at runtime to toggle between packaged and updatable resources, or late configuration from an async load callback.","solutions":["Set the resource mode before initialization, e.g. in Awake or the inspector","Remove runtime mode-switching calls after startup","Rebuild the module if a mode change is genuinely required"],"exampleFix":"// before\nvoid OnDownloadComplete() { resourceComponent.SetResourceMode(ResourceMode.PackageAndUpdatable); } // refused\n// after\nvoid Awake() { resourceComponent.SetResourceMode(ResourceMode.PackageAndUpdatable); }","handlingStrategy":"validation","validationCode":"if (!resourceComponent.Initialized) resourceComponent.SetResourceMode(mode);","typeGuard":null,"tryCatchPattern":"try { resourceComponent.SetResourceMode(mode); }\ncatch (GameFrameworkException) { Log.Error(\"Resource mode must be set before initialization completes.\"); }","preventionTips":["Decide the resource mode at build/bootstrap time","Do not switch modes after startup","Keep all setters in the pre-initialization phase"],"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"}