{"record":{"id":"e9c05f0d89cc9732","repo":"EllanJiang/GameFramework","slug":"you-can-not-change-resource-mode-at-this-time","errorCode":null,"errorMessage":"You can not change resource mode at this time.","messagePattern":"You can not change resource mode at this time\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":958,"sourceCode":"                    m_ResourceChecker.ResourceNeedUpdate += OnCheckerResourceNeedUpdate;\n                    m_ResourceChecker.ResourceCheckComplete += OnCheckerResourceCheckComplete;\n\n                    m_ResourceUpdater = new ResourceUpdater(this);\n                    m_ResourceUpdater.ResourceApplyStart += OnUpdaterResourceApplyStart;\n                    m_ResourceUpdater.ResourceApplySuccess += OnUpdaterResourceApplySuccess;\n                    m_ResourceUpdater.ResourceApplyFailure += OnUpdaterResourceApplyFailure;\n                    m_ResourceUpdater.ResourceApplyComplete += OnUpdaterResourceApplyComplete;\n                    m_ResourceUpdater.ResourceUpdateStart += OnUpdaterResourceUpdateStart;\n                    m_ResourceUpdater.ResourceUpdateChanged += OnUpdaterResourceUpdateChanged;\n                    m_ResourceUpdater.ResourceUpdateSuccess += OnUpdaterResourceUpdateSuccess;\n                    m_ResourceUpdater.ResourceUpdateFailure += OnUpdaterResourceUpdateFailure;\n                    m_ResourceUpdater.ResourceUpdateComplete += OnUpdaterResourceUpdateComplete;\n                    m_ResourceUpdater.ResourceUpdateAllComplete += OnUpdaterResourceUpdateAllComplete;\n                }\n            }\n            else if (m_ResourceMode != resourceMode)\n            {\n                throw new GameFrameworkException(\"You can not change resource mode at this time.\");\n            }\n        }\n\n        /// <summary>\n        /// 设置当前变体。\n        /// </summary>\n        /// <param name=\"currentVariant\">当前变体。</param>\n        public void SetCurrentVariant(string currentVariant)\n        {\n            if (m_RefuseSetFlag)\n            {\n                throw new GameFrameworkException(\"You can not set current variant at this time.\");\n            }\n\n            m_CurrentVariant = currentVariant;\n        }\n\n        /// <summary>","sourceCodeStart":940,"sourceCodeEnd":976,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L940-L976","documentation":"SetResourceMode throws this when the module is already running with a different concrete resource mode (m_ResourceMode != resourceMode and m_ResourceMode != Unspecified). The resource mode is decided once during initialization and cannot be changed while resources are loaded/updated under the old mode.","triggerScenarios":"Calling SetResourceMode a second time with a different, non-Unspecified value after the first call already took effect and the updater was initialized.","commonSituations":"Code paths that call SetResourceMode from two places with different values, or changing mode between editor play sessions via scripts that persist settings.","solutions":["Ensure SetResourceMode is called exactly once with the intended mode","Unify all call sites so they agree on one mode value","If a mode change is required, restart the application/module rather than mutating at runtime"],"exampleFix":"// before\nif (useUpdatable) resourceComponent.SetResourceMode(ResourceMode.PackageAndUpdatable);\nresourceComponent.SetResourceMode(ResourceMode.Package); // second conflicting call\n// after\nvar mode = useUpdatable ? ResourceMode.PackageAndUpdatable : ResourceMode.Package;\nresourceComponent.SetResourceMode(mode); // called once","handlingStrategy":"validation","validationCode":"var current = resourceComponent.ResourceMode;\nif (current != ResourceMode.Unspecified && current != mode)\n    Log.Error(\"Resource mode already set to {0}; refusing {1}\", current, mode);\nelse\n    resourceComponent.SetResourceMode(mode);","typeGuard":null,"tryCatchPattern":"try { resourceComponent.SetResourceMode(mode); }\ncatch (GameFrameworkException) { Log.Error(\"Resource mode is locked after first initialization; use a single mode per session.\"); }","preventionTips":["Call SetResourceMode exactly once from one authoritative place","Derive the mode from a single config source to avoid conflicting values","Never hard-code a second mode elsewhere in code"],"tags":["gameframework","unity","resource","configuration-conflict"],"backgroundTag":"conflicting-config-options","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}