{"record":{"id":"03b9d55baaa81f37","repo":"EllanJiang/GameFramework","slug":"can-not-create-ui-form-in-ui-form-helper","errorCode":null,"errorMessage":"Can not create UI form in UI form helper.","messagePattern":"Can not create UI form in UI form helper\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.cs","lineNumber":947,"sourceCode":"        /// <param name=\"priority\">界面实例优先级。</param>\n        public void SetUIFormInstancePriority(object uiFormInstance, int priority)\n        {\n            if (uiFormInstance == null)\n            {\n                throw new GameFrameworkException(\"UI form instance is invalid.\");\n            }\n\n            m_InstancePool.SetPriority(uiFormInstance, priority);\n        }\n\n        private void InternalOpenUIForm(int serialId, string uiFormAssetName, UIGroup uiGroup, object uiFormInstance, bool pauseCoveredUIForm, bool isNewInstance, float duration, object userData)\n        {\n            try\n            {\n                IUIForm uiForm = m_UIFormHelper.CreateUIForm(uiFormInstance, uiGroup, userData);\n                if (uiForm == null)\n                {\n                    throw new GameFrameworkException(\"Can not create UI form in UI form helper.\");\n                }\n\n                uiForm.OnInit(serialId, uiFormAssetName, uiGroup, pauseCoveredUIForm, isNewInstance, userData);\n                uiGroup.AddUIForm(uiForm);\n                uiForm.OnOpen(userData);\n                uiGroup.Refresh();\n\n                if (m_OpenUIFormSuccessEventHandler != null)\n                {\n                    OpenUIFormSuccessEventArgs openUIFormSuccessEventArgs = OpenUIFormSuccessEventArgs.Create(uiForm, duration, userData);\n                    m_OpenUIFormSuccessEventHandler(this, openUIFormSuccessEventArgs);\n                    ReferencePool.Release(openUIFormSuccessEventArgs);\n                }\n            }\n            catch (Exception exception)\n            {\n                if (m_OpenUIFormFailureEventHandler != null)\n                {","sourceCodeStart":929,"sourceCodeEnd":965,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.cs#L929-L965","documentation":"During InternalOpenUIForm, UIManager asks the registered IUIFormHelper to create the form object from the loaded instance. If the helper returns null the framework cannot continue and throws this GameFrameworkException. It indicates the UI form helper (usually UIFormHelper on the Unity side) failed to build the form component.","triggerScenarios":"CreateUIForm in the custom helper returning null: the loaded asset has no UIForm-derived component (Instantiate added it but GetComponent<UIForm> fails), a custom helper script returns null on error, or the wrong helper is assigned on UIComponent.","commonSituations":"Prefab built without the UIForm script after a refactor; a custom helper expecting a different instance type (e.g. receiving a GameObject but casting to wrong type and swallowing the exception); helper's InstantiateLogic not attached.","solutions":["Ensure the form prefab has a UIForm-derived component and the custom logic script attached","Check your IUIFormHelper.CreateUIForm implementation returns non-null or throws a descriptive error","Verify the UIFormHelper assigned on UIComponent in the inspector is the correct type","Log the loaded asset name inside CreateUIForm to find which prefab is broken"],"exampleFix":"// before (custom helper)\nreturn instance as UIForm;\n// after\nvar form = (instance as GameObject)?.GetComponent<UIFormLogic>();\nif (form == null)\n{\n    Log.Error(\"UIForm component missing on prefab\");\n}\nreturn form;","handlingStrategy":"validation","validationCode":"var form = loadedInstance as GameObject;\nif (form == null || form.GetComponent<UIFormLogic>() == null)\n{\n    Log.Error(\"Prefab {0} missing UIFormLogic\", form ? form.name : loadedInstance);\n    return;\n}","typeGuard":null,"tryCatchPattern":"try { UI.OpenUIForm(assetName, group, userData); } catch (GameFrameworkException ex) { Log.Error(\"UIFormHelper failed: {0}\", ex.Message); }","preventionTips":["Keep UIFormLogic (or UIForm) component on every UI prefab; check after prefab refactors","Verify the UIFormHelper assigned on UIComponent matches your prefab structure","Make CreateUIForm log errors instead of silently returning null","Add a smoke test that opens every UI form once in editor"],"tags":["unity","gameframework","ui","helper","prefab"],"backgroundTag":"missing-dependency","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"}