{"record":{"id":"7766008da74c57b7","repo":"EllanJiang/GameFramework","slug":"resource-helper-is-invalid","errorCode":null,"errorMessage":"Resource helper is invalid.","messagePattern":"Resource helper is invalid\\.","errorType":"validation","errorClass":"GameFrameworkException","httpStatus":null,"severity":"critical","filePath":"GameFramework/Resource/ResourceManager.ResourceChecker.cs","lineNumber":68,"sourceCode":"\n            /// <summary>\n            /// 关闭并清理资源检查器。\n            /// </summary>\n            public void Shutdown()\n            {\n                m_CheckInfos.Clear();\n            }\n\n            /// <summary>\n            /// 检查资源。\n            /// </summary>\n            /// <param name=\"currentVariant\">当前使用的变体。</param>\n            /// <param name=\"ignoreOtherVariant\">是否忽略处理其它变体的资源，若不忽略，将会移除其它变体的资源。</param>\n            public void CheckResources(string currentVariant, bool ignoreOtherVariant)\n            {\n                if (m_ResourceManager.m_ResourceHelper == null)\n                {\n                    throw new GameFrameworkException(\"Resource helper is invalid.\");\n                }\n\n                if (string.IsNullOrEmpty(m_ResourceManager.m_ReadOnlyPath))\n                {\n                    throw new GameFrameworkException(\"Read-only path is invalid.\");\n                }\n\n                if (string.IsNullOrEmpty(m_ResourceManager.m_ReadWritePath))\n                {\n                    throw new GameFrameworkException(\"Read-write path is invalid.\");\n                }\n\n                m_CurrentVariant = currentVariant;\n                m_IgnoreOtherVariant = ignoreOtherVariant;\n                m_ResourceManager.m_ResourceHelper.LoadBytes(Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_ReadWritePath, RemoteVersionListFileName)), new LoadBytesCallbacks(OnLoadUpdatableVersionListSuccess, OnLoadUpdatableVersionListFailure), null);\n                m_ResourceManager.m_ResourceHelper.LoadBytes(Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_ReadOnlyPath, LocalVersionListFileName)), new LoadBytesCallbacks(OnLoadReadOnlyVersionListSuccess, OnLoadReadOnlyVersionListFailure), null);\n                m_ResourceManager.m_ResourceHelper.LoadBytes(Utility.Path.GetRemotePath(Path.Combine(m_ResourceManager.m_ReadWritePath, LocalVersionListFileName)), new LoadBytesCallbacks(OnLoadReadWriteVersionListSuccess, OnLoadReadWriteVersionListFailure), null);\n            }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Resource/ResourceManager.ResourceChecker.cs#L50-L86","documentation":"GameFramework's ResourceChecker.CheckResources starts the resource-check pipeline by loading the remote and local version lists through the ResourceManager's configured IResourceHelper. If m_ResourceHelper is null, no helper has been registered on the resource manager, so the framework cannot load anything and throws this GameFrameworkException immediately.","triggerScenarios":"Calling CheckResources (e.g. via resourceComponent.CheckResources or UpdateResourceAsync) before the ResourceHelper component has been set on the ResourceManager, or after calling SetResourceHelper was never invoked / was passed a null helper.","commonSituations":"Forgetting to add the ResourceHelper component in the Unity GameFramework scene hierarchy; calling resource initialization too early in a custom bootstrap before GameFrameworkComponent initialization; a custom helper assignment that accidentally assigns null.","solutions":["Add the ResourceHelper component (DefaultResourceHelper) to the GameFramework scene and ensure it registers itself with the ResourceComponent.","Call resourceComponent.SetResourceHelper(new DefaultResourceHelper()) (or your custom IResourceHelper) before CheckResources.","Check the order of your startup code so the helper is assigned before any resource update/check call."],"exampleFix":"// before\nm_ResourceComponent.CheckResources(); // helper never set -> throws\n\n// after\nm_ResourceComponent.SetResourceHelper(new DefaultResourceHelper());\nm_ResourceComponent.CheckResources();","handlingStrategy":"type-guard","validationCode":"if (m_ResourceComponent == null)\n    throw new InvalidOperationException(\"ResourceComponent missing\");\n// ensure helper registered before check\nm_ResourceComponent.SetResourceHelper(new DefaultResourceHelper());","typeGuard":"bool IsResourceHelperReady(ResourceComponent c) =>\n    c != null && c.GetComponent<DefaultResourceHelper>() != null;","tryCatchPattern":"try { m_ResourceComponent.CheckResources(); }\ncatch (GameFrameworkException ex) when (ex.Message == \"Resource helper is invalid.\")\n{\n    Debug.LogError(\"ResourceHelper not configured; add it to the GameFramework scene.\");\n}","preventionTips":["Always keep the stock GameFramework ResourceHelper component in the bootstrap scene.","Call SetResourceHelper explicitly in your entry-point script before any resource operation.","Add a startup assertion that the helper is registered."],"tags":["gameframework","resource","null-helper","initialization-order"],"backgroundTag":"null-argument","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"}