{"record":{"id":"9457e3ee6d00117d","repo":"EllanJiang/GameFramework","slug":"ui-group-helper-is-invalid-uimanager","errorCode":null,"errorMessage":"UI group helper is invalid.","messagePattern":"UI group helper is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.cs","lineNumber":379,"sourceCode":"        }\n\n        /// <summary>\n        /// 增加界面组。\n        /// </summary>\n        /// <param name=\"uiGroupName\">界面组名称。</param>\n        /// <param name=\"uiGroupDepth\">界面组深度。</param>\n        /// <param name=\"uiGroupHelper\">界面组辅助器。</param>\n        /// <returns>是否增加界面组成功。</returns>\n        public bool AddUIGroup(string uiGroupName, int uiGroupDepth, IUIGroupHelper uiGroupHelper)\n        {\n            if (string.IsNullOrEmpty(uiGroupName))\n            {\n                throw new GameFrameworkException(\"UI group name is invalid.\");\n            }\n\n            if (uiGroupHelper == null)\n            {\n                throw new GameFrameworkException(\"UI group helper is invalid.\");\n            }\n\n            if (HasUIGroup(uiGroupName))\n            {\n                return false;\n            }\n\n            m_UIGroups.Add(uiGroupName, new UIGroup(uiGroupName, uiGroupDepth, uiGroupHelper));\n\n            return true;\n        }\n\n        /// <summary>\n        /// 是否存在界面。\n        /// </summary>\n        /// <param name=\"serialId\">界面序列编号。</param>\n        /// <returns>是否存在界面。</returns>\n        public bool HasUIForm(int serialId)","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.cs#L361-L397","documentation":"AddUIGroup requires an IUIGroupHelper to create the underlying group; it throws this GameFrameworkException when the uiGroupHelper argument is null. The helper handles the platform-specific instantiation of UI group objects, so a null helper would break group creation immediately after registration. The name check runs first, then this check, then the duplicate-name short-circuit.","triggerScenarios":"Calling AddUIGroup(name, depth, null) — usually because the helper factory returned null, or setup code passes a helper obtained from an unassigned field.","commonSituations":"Unity projects that forgot to construct their UGUI/UICustomGroupHelper before registering groups; conditional platform code that only creates the helper on some platforms; DI containers that resolved the helper to null.","solutions":["Pass a constructed helper, e.g. ui.AddUIGroup(\"Main\", 1, new UIGroupHelper())","Verify helper initialization ran before group registration in the startup sequence","Check platform-conditional code paths so the helper exists on all target platforms","Create the helper inline in AddUIGroup calls if no shared instance is needed"],"exampleFix":"// before\nIUIGroupHelper helper = CreateHelper(); // may return null on this platform\nui.AddUIGroup(\"Main\", 1, helper);\n// after\nIUIGroupHelper helper = CreateHelper() ?? new DefaultUIGroupHelper();\nui.AddUIGroup(\"Main\", 1, helper);","handlingStrategy":"validation","validationCode":"if (uiGroupHelper == null)\n    uiGroupHelper = new DefaultUIGroupHelper();\nuiManager.AddUIGroup(groupName, depth, uiGroupHelper);","typeGuard":"bool IsValidHelper(IUIGroupHelper h) => h != null;","tryCatchPattern":"try { uiManager.AddUIGroup(name, depth, helper); }\ncatch (GameFrameworkException ex) { Debug.LogError($\"AddUIGroup failed: {ex.Message}\"); }","preventionTips":["Construct the group helper in the same startup method that registers groups","Check platform-specific helper creation for all build targets","Provide a default/fallback helper instead of a nullable helper field"],"tags":["null-argument","ui","helper"],"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"}