{"record":{"id":"b551f1e9b3dae976","repo":"EllanJiang/GameFramework","slug":"you-can-not-use-stopupdateresources-without-updatable","errorCode":null,"errorMessage":"You can not use StopUpdateResources without updatable resource mode.","messagePattern":"You can not use StopUpdateResources without updatable resource mode\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1341,"sourceCode":"            }\n\n            m_UpdateResourcesCompleteCallback = updateResourcesCompleteCallback;\n            m_ResourceUpdater.UpdateResources(resourceGroup);\n        }\n\n        /// <summary>\n        /// 停止更新资源。\n        /// </summary>\n        public void StopUpdateResources()\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 StopUpdateResources without updatable resource mode.\");\n            }\n\n            if (m_ResourceUpdater == null)\n            {\n                throw new GameFrameworkException(\"You can not use StopUpdateResources at this time.\");\n            }\n\n            m_ResourceUpdater.StopUpdateResources();\n            m_UpdateResourcesCompleteCallback = null;\n        }\n\n        /// <summary>\n        /// 校验资源包。\n        /// </summary>\n        /// <param name=\"resourcePackPath\">要校验的资源包路径。</param>\n        /// <returns>是否校验资源包成功。</returns>\n        public bool VerifyResourcePack(string resourcePackPath)\n        {","sourceCodeStart":1323,"sourceCodeEnd":1359,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1323-L1359","documentation":"StopUpdateResources() is only meaningful when the game runs in an updatable resource mode (Updatable or UpdatableWhilePlaying). ResourceManager throws this GameFrameworkException during the pre-checks of StopUpdateResources when the current m_ResourceMode is not one of those two modes, because there is nothing updatable to stop. It is a guard against calling a feature that the current resource configuration does not support.","triggerScenarios":"Calling ResourceManager.StopUpdateResources() while m_ResourceMode is ResourceMode.Unspecified or ResourceMode.Package (i.e. resource mode was never set or set to package-only mode before/instead of calling UpdateResourceAsync).","commonSituations":"Developers switch a demo from Package mode to a shipping updatable build but leave the StopUpdateResources call in a cleanup path; or they call StopUpdateResources before InitializeResourceMode/setting the mode, hitting the mode check first.","solutions":["Set the resource mode to ResourceMode.Updatable or ResourceMode.UpdatableWhilePlaying before calling StopUpdateResources.","Only call StopUpdateResources after UpdateResourceAsync has actually started updating in an updatable mode.","Wrap the call in a mode check: if (resourceManager.ResourceMode == ResourceMode.Updatable || resourceManager.ResourceMode == ResourceMode.UpdatableWhilePlaying) { ... }"],"exampleFix":"// before\nresourceManager.StopUpdateResources(); // throws in Package mode\n// after\nif (resourceManager.ResourceMode == ResourceMode.Updatable || resourceManager.ResourceMode == ResourceMode.UpdatableWhilePlaying)\n{\n    resourceManager.StopUpdateResources();\n}","handlingStrategy":"validation","validationCode":"bool canStop = rm.ResourceMode == ResourceMode.Updatable || rm.ResourceMode == ResourceMode.UpdatableWhilePlaying;\nif (!canStop) return;","typeGuard":"static bool IsUpdatableMode(ResourceMode mode) => mode == ResourceMode.Updatable || mode == ResourceMode.UpdatableWhilePlaying;","tryCatchPattern":"try { rm.StopUpdateResources(); } catch (GameFrameworkException ex) { Log.Warn(\"Cannot stop update: \" + ex.Message); }","preventionTips":["Check ResourceMode before calling any update-related API","Only call StopUpdateResources inside an active update flow","Centralize resource-mode queries in one helper"],"tags":["gameframework","resource-mode","updatable-resources","api-misuse"],"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"}