{"record":{"id":"c5cc15effdf5a629","repo":"EllanJiang/GameFramework","slug":"you-can-not-use-initresources-at-this-time","errorCode":null,"errorMessage":"You can not use InitResources at this time.","messagePattern":"You can not use InitResources at this time\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Resource/ResourceManager.cs","lineNumber":1107,"sourceCode":"        {\n            if (initResourcesCompleteCallback == null)\n            {\n                throw new GameFrameworkException(\"Init 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.Package)\n            {\n                throw new GameFrameworkException(\"You can not use InitResources without package resource mode.\");\n            }\n\n            if (m_ResourceIniter == null)\n            {\n                throw new GameFrameworkException(\"You can not use InitResources at this time.\");\n            }\n\n            m_RefuseSetFlag = true;\n            m_InitResourcesCompleteCallback = initResourcesCompleteCallback;\n            m_ResourceIniter.InitResources(m_CurrentVariant);\n        }\n\n        /// <summary>\n        /// 使用可更新模式并检查版本资源列表。\n        /// </summary>\n        /// <param name=\"latestInternalResourceVersion\">最新的内部资源版本号。</param>\n        /// <returns>检查版本资源列表结果。</returns>\n        public CheckVersionListResult CheckVersionList(int latestInternalResourceVersion)\n        {\n            if (m_ResourceMode == ResourceMode.Unspecified)\n            {\n                throw new GameFrameworkException(\"You must set resource mode first.\");\n            }","sourceCodeStart":1089,"sourceCodeEnd":1125,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.cs#L1089-L1125","documentation":"Thrown by ResourceManager.InitResources when m_ResourceIniter is null. Even in Package mode, the internal ResourceIniter component must have been created/attached (via the framework component setup) before InitResources can delegate to it.","triggerScenarios":"Calling InitResources in Package mode before the ResourceIniter helper has been initialized, or after the ResourceManager was torn down / partially constructed outside the normal GameFramework component lifecycle.","commonSituations":"Manually constructing ResourceManager without the Unity ResourceComponent's Awake creating helpers, calling InitResources too early in the frame, or destroying the component then reusing it.","solutions":["Ensure the GameFramework ResourceComponent has fully initialized (Awake created all helper components) before calling InitResources.","Do not create a raw ResourceManager yourself; use the provided component lifecycle.","Re-add/repair the ResourceIniter helper if it was removed or destroyed."],"exampleFix":"// before\nvar rm = new ResourceManager();\nrm.InitResources(OnInitResourcesComplete);\n// after\n// use the GameFramework ResourceComponent lifecycle\nm_ResourceComponent.InitResources(OnInitResourcesComplete);","handlingStrategy":"validation","validationCode":"if (!m_ResourceComponent.Ready) yield return new WaitUntil(() => m_ResourceComponent.Ready);\nm_ResourceComponent.InitResources(OnInitResourcesComplete);","typeGuard":null,"tryCatchPattern":"try { m_ResourceComponent.InitResources(cb); }\ncatch (GameFrameworkException e) { Log.Fatal(\"ResourceIniter not ready: {0}\", e.Message); }","preventionTips":["Use the GameFramework ResourceComponent lifecycle instead of constructing ResourceManager directly.","Call init APIs only after component Awake completed.","Do not destroy resource helper components mid-run."],"tags":["unity","gameframework","resource-manager","missing-dependency","lifecycle"],"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"}