{"record":{"id":"b5b59c7075f9a93b","repo":"EllanJiang/GameFramework","slug":"you-can-not-set-current-variant-at-this-time","errorCode":null,"errorMessage":"You can not set current variant at this time.","messagePattern":"You can not set current variant at this time\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":970,"sourceCode":"                    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>\n        /// 设置对象池管理器。\n        /// </summary>\n        /// <param name=\"objectPoolManager\">对象池管理器。</param>\n        public void SetObjectPoolManager(IObjectPoolManager objectPoolManager)\n        {\n            if (objectPoolManager == null)\n            {\n                throw new GameFrameworkException(\"Object pool manager is invalid.\");\n            }\n\n            m_ResourceLoader.SetObjectPoolManager(objectPoolManager);\n        }","sourceCodeStart":952,"sourceCodeEnd":988,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L952-L988","documentation":"SetCurrentVariant throws this when m_RefuseSetFlag is true, meaning the resource module is already initialized and configuration setters are locked. The current variant (e.g. language/quality asset variant) must be chosen before initialization completes.","triggerScenarios":"Calling SetCurrentVariant after ResourceManager initialization has completed.","commonSituations":"Choosing a variant based on user settings loaded asynchronously after startup, or switching language variants at runtime.","solutions":["Set the variant before initialization (Awake / inspector / bootstrap)","Load variant settings synchronously before the resource module initializes","Do not switch variants at runtime; restart the module if necessary"],"exampleFix":"// before\nIEnumerator Start() { yield return LoadUserPrefs(); resourceComponent.SetCurrentVariant(prefs.Variant); } // refused\n// after\nvoid Awake() { resourceComponent.SetCurrentVariant(syncedPrefs.Variant); }","handlingStrategy":"validation","validationCode":"if (!resourceComponent.Initialized) resourceComponent.SetCurrentVariant(variant); else Log.Warning(\"Too late to set current variant\");","typeGuard":null,"tryCatchPattern":"try { resourceComponent.SetCurrentVariant(variant); }\ncatch (GameFrameworkException) { Log.Error(\"Current variant must be set before resource initialization completes.\"); }","preventionTips":["Load variant/user preferences synchronously before init","Set the variant in the bootstrap phase (Awake)","Avoid runtime variant switching; restart the module if needed"],"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-16T04:17:20.429Z"}