EllanJiang/GameFramework · error · GameFrameworkException

UI form is invalid.

Error message

UI form is invalid.

What it means

UIManager.UIGroup.UIFormInfo.Create wraps an IUIForm and throws when uiForm is null. UIFormInfo is the group's internal record of a live form; a null form would crash depth/pause/cover bookkeeping in the UIGroup linked list.

Solutions

  1. Fix the IUIFormHelper.InstantiateUIForm implementation so it never returns null — throw or log on failure.
  2. Verify the UI form prefab has the script implementing IUIForm (UIFormLogic subclass) on its root.
  3. Open forms through the standard OpenUIForm flow so assets load before instantiation.

Example fix

// before
public object InstantiateUIForm(object uiFormAsset) { return null; }
// after
public object InstantiateUIForm(object uiFormAsset)
{
    var go = Object.Instantiate((UnityEngine.Object)uiFormAsset) as GameObject;
    if (go == null) throw new GameFrameworkException("InstantiateUIForm failed.");
    return go;
}
Defensive patterns

Strategy: validation

Validate before calling

if (uiForm == null)
{
    Log.Error("InstantiateUIForm returned null; cannot add to group");
    return;
}

Type guard

bool IsValidForm(IUIForm f) => f != null && !string.IsNullOrEmpty(f.UIFormAssetName);

Try / catch

try { uiGroup.AddUIForm(uiForm); }
catch (GameFrameworkException ex) { Log.Error(ex, "Null UI form handed to group"); }

Prevention

When it happens

Trigger: UIGroup.AddUIForm (or direct UIFormInfo.Create usage) receives a null IUIForm — i.e. an instance object whose instantiated form is null, typically because the custom UI form helper's InstantiateUIForm returned null.

Common situations: Custom IUIFormHelper.InstantiateUIForm implementations returning null on failure instead of throwing; prefab with missing/incorrect root component; pool holding a cleared instance object.

Related errors


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

Appendix: source

Thrown at GameFramework/UI/UIManager.UIGroup.UIFormInfo.cs:66

                }

                public bool Covered
                {
                    get
                    {
                        return m_Covered;
                    }
                    set
                    {
                        m_Covered = value;
                    }
                }

                public static UIFormInfo Create(IUIForm uiForm)
                {
                    if (uiForm == null)
                    {
                        throw new GameFrameworkException("UI form is invalid.");
                    }

                    UIFormInfo uiFormInfo = ReferencePool.Acquire<UIFormInfo>();
                    uiFormInfo.m_UIForm = uiForm;
                    uiFormInfo.m_Paused = true;
                    uiFormInfo.m_Covered = true;
                    return uiFormInfo;
                }

                public void Clear()
                {
                    m_UIForm = null;
                    m_Paused = false;
                    m_Covered = false;
                }
            }
        }
    }

View on GitHub (pinned to d0c010b051)