EllanJiang/GameFramework · error · GameFrameworkException

UI form asset is invalid.

Error message

UI form asset is invalid.

What it means

UIManager.UIFormInstanceObject.Create validates its arguments and throws when the uiFormAsset parameter is null. An instance object tracks the raw asset that instantiated a UI form, so a null asset would break release/shutdown logic that calls the helper's release methods.

Solutions

  1. Ensure the UI form asset is loaded successfully before creating its instance object.
  2. Pass the actual asset object returned by the asset loader into Create.
  3. Audit custom IUIFormHelper code that constructs UIFormInstanceObject manually.
  4. Use the standard UIManager.OpenUIForm path instead of manual instance-object creation.

Example fix

// before
var inst = UIFormInstanceObject.Create(name, null, uiForm, helper);
// after
object asset = await LoadUiFormAssetAsync(name);
var inst = UIFormInstanceObject.Create(name, asset, uiForm, helper);
Defensive patterns

Strategy: validation

Validate before calling

if (uiFormAsset == null)
{
    Log.Error("Cannot create UIFormInstanceObject: asset not loaded");
    return;
}

Type guard

if (uiFormAsset is UnityEngine.Object o && o != null) { /* valid */ }

Try / catch

try { var inst = UIFormInstanceObject.Create(name, asset, uiForm, helper); }
catch (GameFrameworkException ex) { Log.Error(ex, "UI form instance creation failed"); }

Prevention

When it happens

Trigger: Calling UIFormInstanceObject.Create directly (or via a custom IObjectPoolManager/IUIFormHelper integration) with a null uiFormAsset — typically when creating instance objects for forms that were never actually loaded.

Common situations: Custom UI helper implementations bypassing UIManager's normal OpenUIForm flow; passing an unloaded asset placeholder; refactoring that changed load success callbacks to pass null assets.

Related errors


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

Appendix: source

Thrown at GameFramework/UI/UIManager.UIFormInstanceObject.cs:32

        /// <summary>
        /// 界面实例对象。
        /// </summary>
        private sealed class UIFormInstanceObject : ObjectBase
        {
            private object m_UIFormAsset;
            private IUIFormHelper m_UIFormHelper;

            public UIFormInstanceObject()
            {
                m_UIFormAsset = null;
                m_UIFormHelper = null;
            }

            public static UIFormInstanceObject Create(string name, object uiFormAsset, object uiFormInstance, IUIFormHelper uiFormHelper)
            {
                if (uiFormAsset == null)
                {
                    throw new GameFrameworkException("UI form asset is invalid.");
                }

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

                UIFormInstanceObject uiFormInstanceObject = ReferencePool.Acquire<UIFormInstanceObject>();
                uiFormInstanceObject.Initialize(name, uiFormInstance);
                uiFormInstanceObject.m_UIFormAsset = uiFormAsset;
                uiFormInstanceObject.m_UIFormHelper = uiFormHelper;
                return uiFormInstanceObject;
            }

            public override void Clear()
            {
                base.Clear();
                m_UIFormAsset = null;

View on GitHub (pinned to d0c010b051)