{"record":{"id":"7fe82a4c4c43d2f1","repo":"EllanJiang/GameFramework","slug":"you-must-set-download-manager-first","errorCode":null,"errorMessage":"You must set download manager first.","messagePattern":"You must set download manager first\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.ResourceUpdater.cs","lineNumber":406,"sourceCode":"                    if (m_ApplyingResourcePackStream != null)\n                    {\n                        m_ApplyingResourcePackStream.Dispose();\n                        m_ApplyingResourcePackStream = null;\n                    }\n\n                    throw new GameFrameworkException(Utility.Text.Format(\"Apply resources '{0}' with exception '{1}'.\", resourcePackPath, exception), exception);\n                }\n            }\n\n            /// <summary>\n            /// 更新指定资源组的资源。\n            /// </summary>\n            /// <param name=\"resourceGroup\">要更新的资源组。</param>\n            public void UpdateResources(ResourceGroup resourceGroup)\n            {\n                if (m_DownloadManager == null)\n                {\n                    throw new GameFrameworkException(\"You must set download manager first.\");\n                }\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 (string.IsNullOrEmpty(resourceGroup.Name))","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceUpdater.cs#L388-L424","documentation":"UpdateResources requires a DownloadManager to fetch remote resource files. The ResourceManager throws this guard exception immediately when m_DownloadManager is null, i.e. SetDownloadManager was never called on the resource component before requesting an update.","triggerScenarios":"Calling UpdateResources(resourceGroup) before ResourceManager.SetDownloadManager(downloadManager) has been called with an initialized DownloadManager.","commonSituations":"Initialization order mistakes: the update flow starts before the download component is created/registered, or the download manager setup line was removed or runs conditionally and never executes.","solutions":["Call resourceComponent.SetDownloadManager(downloadComponent) during startup before any UpdateResources call.","Verify the download manager component is added/enabled in the scene or created in code before the update step.","Gate the update flow behind an init-complete flag that is only set after both CheckResources and SetDownloadManager finished."],"exampleFix":"// before\nresourceComponent.UpdateResources(resourceGroup);\n// after\nresourceComponent.SetDownloadManager(downloadComponent);\nresourceComponent.UpdateResources(resourceGroup);","handlingStrategy":"validation","validationCode":"if (downloadComponent == null || !m_DownloadManagerSet) { throw new InvalidOperationException(\"Call SetDownloadManager before UpdateResources\"); }\nresourceComponent.UpdateResources(resourceGroup);","typeGuard":"bool DownloadManagerReady => downloadComponent != null && m_DownloadManagerSet;","tryCatchPattern":"try { resourceComponent.UpdateResources(group); }\ncatch (GameFrameworkException ex) when (ex.Message.Contains(\"download manager\"))\n{\n    Log.Error(\"Update pipeline not initialized: call SetDownloadManager first\");\n}","preventionTips":["Call SetDownloadManager at a single bootstrap point before any update API","Enforce an init order: create components -> SetDownloadManager -> CheckResources -> update","Add an assert/log line confirming download manager is set before entering update flow"],"tags":["initialization-order","missing-dependency","gameframework"],"backgroundTag":"missing-dependency","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"}