{"record":{"id":"4579c46014b00bdf","repo":"EllanJiang/GameFramework","slug":"you-can-not-use-applyresources-without-updatable-resource","errorCode":null,"errorMessage":"You can not use ApplyResources without updatable resource mode.","messagePattern":"You can not use ApplyResources without updatable resource mode\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1271,"sourceCode":"\n            if (!File.Exists(resourcePackPath))\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Resource pack '{0}' is not exist.\", resourcePackPath));\n            }\n\n            if (applyResourcesCompleteCallback == null)\n            {\n                throw new GameFrameworkException(\"Apply resources complete callback is invalid.\");\n            }\n\n            if (m_ResourceMode == ResourceMode.Unspecified)\n            {\n                throw new GameFrameworkException(\"You must set resource mode first.\");\n            }\n\n            if (m_ResourceMode != ResourceMode.Updatable && m_ResourceMode != ResourceMode.UpdatableWhilePlaying)\n            {\n                throw new GameFrameworkException(\"You can not use ApplyResources without updatable resource mode.\");\n            }\n\n            if (m_ResourceUpdater == null)\n            {\n                throw new GameFrameworkException(\"You can not use ApplyResources at this time.\");\n            }\n\n            m_ApplyResourcesCompleteCallback = applyResourcesCompleteCallback;\n            m_ResourceUpdater.ApplyResources(resourcePackPath);\n        }\n\n        /// <summary>\n        /// 使用可更新模式并更新所有资源。\n        /// </summary>\n        /// <param name=\"updateResourcesCompleteCallback\">使用可更新模式并更新默认资源组完成时的回调函数。</param>\n        public void UpdateResources(UpdateResourcesCompleteCallback updateResourcesCompleteCallback)\n        {\n            UpdateResources(string.Empty, updateResourcesCompleteCallback);","sourceCodeStart":1253,"sourceCodeEnd":1289,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1253-L1289","documentation":"This GameFrameworkException is thrown by ResourceManager.ApplyResources when the configured ResourceMode is neither Updatable nor UpdatableWhilePlaying (e.g. Package mode). Applying a downloaded resource pack only makes sense when resources are updatable, so the API rejects the call in fixed-package mode. It is a mode-compatibility guard.","triggerScenarios":"Calling ApplyResources while m_ResourceMode is ResourceMode.Package or ResourceMode.Unspecified; an app configured for non-updatable mode invoking pack-apply logic (e.g. after a config that disables hot-update).","commonSituations":"Build configuration mistakenly set to Package mode in an app that also performs hot updates; shared code paths that call ApplyResources regardless of the selected mode; QA toggles switching resource mode without guarding call sites.","solutions":["Set ResourceMode to Updatable or UpdatableWhilePlaying when the game needs ApplyResources.","Guard the ApplyResources call with a check of ResourceManager.ResourceMode before invoking it.","Remove or branch off the ApplyResources call for Package-mode builds."],"exampleFix":"// before\nresourceManager.ApplyResources(packPath, callback);\n// after\nif (resourceManager.ResourceMode == ResourceMode.Updatable || resourceManager.ResourceMode == ResourceMode.UpdatableWhilePlaying)\n{\n    resourceManager.ApplyResources(packPath, callback);\n}","handlingStrategy":"validation","validationCode":"var mode = resourceManager.ResourceMode;\nif (mode != ResourceMode.Updatable && mode != ResourceMode.UpdatableWhilePlaying) return; // skip apply in non-updatable modes","typeGuard":"bool IsUpdatableMode(ResourceMode m) => m == ResourceMode.Updatable || m == ResourceMode.UpdatableWhilePlaying;","tryCatchPattern":"try { resourceManager.ApplyResources(packPath, callback); }\ncatch (GameFrameworkException ex) when (ex.Message.Contains(\"updatable resource mode\")) { UnityEngine.Debug.LogWarning(\"ApplyResources not available in this resource mode.\"); }","preventionTips":["Match build configuration (Package vs Updatable) to the APIs your code calls.","Gate hot-update-only APIs behind mode checks or conditional compilation.","Document which resource APIs require which mode."],"tags":["csharp","gameframework","resource-mode","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}