{"record":{"id":"5b60ad2fb29ae8f2","repo":"EllanJiang/GameFramework","slug":"ui-form-asset-is-invalid","errorCode":null,"errorMessage":"UI form asset is invalid.","messagePattern":"UI form asset is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.UIFormInstanceObject.cs","lineNumber":32,"sourceCode":"        /// <summary>\n        /// 界面实例对象。\n        /// </summary>\n        private sealed class UIFormInstanceObject : ObjectBase\n        {\n            private object m_UIFormAsset;\n            private IUIFormHelper m_UIFormHelper;\n\n            public UIFormInstanceObject()\n            {\n                m_UIFormAsset = null;\n                m_UIFormHelper = null;\n            }\n\n            public static UIFormInstanceObject Create(string name, object uiFormAsset, object uiFormInstance, IUIFormHelper uiFormHelper)\n            {\n                if (uiFormAsset == null)\n                {\n                    throw new GameFrameworkException(\"UI form asset is invalid.\");\n                }\n\n                if (uiFormHelper == null)\n                {\n                    throw new GameFrameworkException(\"UI form helper is invalid.\");\n                }\n\n                UIFormInstanceObject uiFormInstanceObject = ReferencePool.Acquire<UIFormInstanceObject>();\n                uiFormInstanceObject.Initialize(name, uiFormInstance);\n                uiFormInstanceObject.m_UIFormAsset = uiFormAsset;\n                uiFormInstanceObject.m_UIFormHelper = uiFormHelper;\n                return uiFormInstanceObject;\n            }\n\n            public override void Clear()\n            {\n                base.Clear();\n                m_UIFormAsset = null;","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.UIFormInstanceObject.cs#L14-L50","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the UI form asset is loaded successfully before creating its instance object.","Pass the actual asset object returned by the asset loader into Create.","Audit custom IUIFormHelper code that constructs UIFormInstanceObject manually.","Use the standard UIManager.OpenUIForm path instead of manual instance-object creation."],"exampleFix":"// before\nvar inst = UIFormInstanceObject.Create(name, null, uiForm, helper);\n// after\nobject asset = await LoadUiFormAssetAsync(name);\nvar inst = UIFormInstanceObject.Create(name, asset, uiForm, helper);","handlingStrategy":"validation","validationCode":"if (uiFormAsset == null)\n{\n    Log.Error(\"Cannot create UIFormInstanceObject: asset not loaded\");\n    return;\n}","typeGuard":"if (uiFormAsset is UnityEngine.Object o && o != null) { /* valid */ }","tryCatchPattern":"try { var inst = UIFormInstanceObject.Create(name, asset, uiForm, helper); }\ncatch (GameFrameworkException ex) { Log.Error(ex, \"UI form instance creation failed\"); }","preventionTips":["Only create instance objects after a successful asset load","Use UIManager.OpenUIForm instead of manual instance-object construction","Handle Unity's overloaded == null for destroyed UnityEngine.Objects"],"tags":["unity","gameframework","ui","null-argument"],"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"}