EllanJiang/GameFramework · error · GameFrameworkException

UI group name is invalid.

Error message

UI group name is invalid.

What it means

The UIGroup constructor validates its name and throws when it is null or empty. Group names are used as dictionary keys in UIManager and shown in logs, so a blank name would corrupt group lookup and event routing.

Solutions

  1. Pass a non-empty group name to UIComponent.AddUIGroup / UIManager.AddUIGroup.
  2. Check config-driven group names for missing values before calling AddUIGroup.
  3. Add a startup assertion that all configured group names are non-empty.

Example fix

// before
UIComponent.AddUIGroup(groupName, depth); // groupName == ""
// after
if (string.IsNullOrEmpty(groupName)) throw new ArgumentException("Group name required");
UIComponent.AddUIGroup(groupName, depth);
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrEmpty(groupName))
{
    Log.Error("UIGroup name must be non-empty");
    return;
}
UIComponent.AddUIGroup(groupName, depth);

Try / catch

try { UIComponent.AddUIGroup(groupName, depth); }
catch (GameFrameworkException ex) { Log.Error(ex, "Invalid UI group name"); }

Prevention

When it happens

Trigger: AddUIGroup (UIManager) or direct UIGroup construction with string.IsNullOrEmpty(name) — e.g. a constant defined as empty string, or a group name read from uninitialized config.

Common situations: UI group name loaded from a config table/ScriptableObject that lacks a value; typo leaving a name field empty; calling AddUIGroup with a variable not yet assigned.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/1ad34d57e842360e. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/UI/UIManager.UIGroup.cs:36

        {
            private readonly string m_Name;
            private int m_Depth;
            private bool m_Pause;
            private readonly IUIGroupHelper m_UIGroupHelper;
            private readonly GameFrameworkLinkedList<UIFormInfo> m_UIFormInfos;
            private LinkedListNode<UIFormInfo> m_CachedNode;

            /// <summary>
            /// 初始化界面组的新实例。
            /// </summary>
            /// <param name="name">界面组名称。</param>
            /// <param name="depth">界面组深度。</param>
            /// <param name="uiGroupHelper">界面组辅助器。</param>
            public UIGroup(string name, int depth, IUIGroupHelper uiGroupHelper)
            {
                if (string.IsNullOrEmpty(name))
                {
                    throw new GameFrameworkException("UI group name is invalid.");
                }

                if (uiGroupHelper == null)
                {
                    throw new GameFrameworkException("UI group helper is invalid.");
                }

                m_Name = name;
                m_Pause = false;
                m_UIGroupHelper = uiGroupHelper;
                m_UIFormInfos = new GameFrameworkLinkedList<UIFormInfo>();
                m_CachedNode = null;
                Depth = depth;
            }

            /// <summary>
            /// 获取界面组名称。
            /// </summary>

View on GitHub (pinned to d0c010b051)