{"record":{"id":"e0e8a7a2ff999ef3","repo":"EllanJiang/GameFramework","slug":"you-must-check-resources-complete-first","errorCode":null,"errorMessage":"You must check resources complete first.","messagePattern":"You must check resources complete first\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceUpdater.cs","lineNumber":320,"sourceCode":"            /// <param name=\"needGenerateReadWriteVersionList\">是否需要生成读写区版本资源列表。</param>\n            public void CheckResourceComplete(bool needGenerateReadWriteVersionList)\n            {\n                m_CheckResourcesComplete = true;\n                if (needGenerateReadWriteVersionList)\n                {\n                    GenerateReadWriteVersionList();\n                }\n            }\n\n            /// <summary>\n            /// 应用指定资源包的资源。\n            /// </summary>\n            /// <param name=\"resourcePackPath\">要应用的资源包路径。</param>\n            public void ApplyResources(string resourcePackPath)\n            {\n                if (!m_CheckResourcesComplete)\n                {\n                    throw new GameFrameworkException(\"You must check resources complete first.\");\n                }\n\n                if (m_ApplyingResourcePackStream != null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"There is already a resource pack '{0}' being applied.\", m_ApplyingResourcePackPath));\n                }\n\n                if (m_UpdatingResourceGroup != null)\n                {\n                    throw new GameFrameworkException(Utility.Text.Format(\"There is already a resource group '{0}' being updated.\", m_UpdatingResourceGroup.Name));\n                }\n\n                if (m_UpdateWaitingInfoWhilePlaying.Count > 0)\n                {\n                    throw new GameFrameworkException(\"There are already some resources being updated while playing.\");\n                }\n\n                try","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceUpdater.cs#L302-L338","documentation":"ResourceManager.ApplyResources throws this when UpdateResources/CheckResources has not completed before applying a resource pack. Applying a pack requires an up-to-date in-memory resource version list; the m_CheckResourcesComplete flag guards that precondition.","triggerScenarios":"Calling ApplyResources(resourcePackPath) immediately after startup, before CheckResources completed and its completion callback fired; calling it from a scene-load path that skips resource checking.","commonSituations":"Applying a downloaded resource pack on app launch without waiting for the check-complete callback; calling ApplyResources from the wrong lifecycle hook; resetting the resource manager after the check and forgetting to re-check.","solutions":["Wait for the CheckResources completion callback (or UpdateResources completion) before calling ApplyResources","Gate ApplyResources behind the resource-check-complete event/flag in your flow","If the manager was reinitialized, run CheckResources again before applying any pack"],"exampleFix":"// before\nresourceManager.ApplyResources(packPath); // too early\n// after\nm_NeedApplyPack = packPath;\nresourceManager.CheckResources(OnCheckResourcesComplete);\n...\nvoid OnCheckResourcesComplete(...) { if (m_NeedApplyPack != null) resourceManager.ApplyResources(m_NeedApplyPack); }","handlingStrategy":"try-catch","validationCode":"// ensure check completed first; gate behind your own flag\nif (!m_ResourcesChecked) throw new InvalidOperationException(\"Call CheckResources and wait for completion before ApplyResources\");","typeGuard":null,"tryCatchPattern":"try { resourceManager.ApplyResources(packPath); } catch (GameFrameworkException ex) { Log.Error(\"ApplyResources called before check completed: \" + ex.Message); }","preventionTips":["Always run CheckResources (and await its callback) at startup before pack operations","Gate ApplyResources behind the resource-check-complete event in your flow","Re-run the check if the resource manager was reinitialized"],"tags":["csharp","gameframework","invalid-state","lifecycle"],"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"}