{"record":{"id":"e707c8d1b1deb0ce","repo":"EllanJiang/GameFramework","slug":"ui-form-asset-name-is-invalid-uimanager","errorCode":null,"errorMessage":"UI form asset name is invalid.","messagePattern":"UI form asset name is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/UI/UIManager.cs","lineNumber":419,"sourceCode":"                if (uiGroup.Value.HasUIForm(serialId))\n                {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n\n        /// <summary>\n        /// 是否存在界面。\n        /// </summary>\n        /// <param name=\"uiFormAssetName\">界面资源名称。</param>\n        /// <returns>是否存在界面。</returns>\n        public bool HasUIForm(string uiFormAssetName)\n        {\n            if (string.IsNullOrEmpty(uiFormAssetName))\n            {\n                throw new GameFrameworkException(\"UI form asset name is invalid.\");\n            }\n\n            foreach (KeyValuePair<string, UIGroup> uiGroup in m_UIGroups)\n            {\n                if (uiGroup.Value.HasUIForm(uiFormAssetName))\n                {\n                    return true;\n                }\n            }\n\n            return false;\n        }\n\n        /// <summary>\n        /// 获取界面。\n        /// </summary>\n        /// <param name=\"serialId\">界面序列编号。</param>\n        /// <returns>要获取的界面。</returns>","sourceCodeStart":401,"sourceCodeEnd":437,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/UI/UIManager.cs#L401-L437","documentation":"HasUIForm searches all UI groups for a form with the given asset name. It throws this GameFrameworkException when uiFormAssetName is null or empty, because an empty asset name cannot identify any form and would silently return false, hiding caller bugs. The name is the same identifier used when the form was opened via OpenUIForm.","triggerScenarios":"Calling HasUIForm(null) or HasUIForm(\"\") — e.g. when the asset name comes from an unassigned field, a failed lookup in a name table, or an empty inspector string.","commonSituations":"UI logic scripts checking whether a form exists before closing it, where the form name constant was renamed or left empty; config-driven close-all-except flows with blank exceptions; asset-name tables missing entries after a resource reorganization.","solutions":["Pass the exact asset name string used in OpenUIForm","Guard the call: if (string.IsNullOrEmpty(assetName)) return false;","Centralize form asset names in a constants class to avoid empty/renamed literals","Verify resource-rename refactors updated every usage site"],"exampleFix":"// before\nbool has = ui.HasUIForm(formName);\n// after\nbool has = !string.IsNullOrEmpty(formName) && ui.HasUIForm(formName);","handlingStrategy":"validation","validationCode":"bool exists = !string.IsNullOrEmpty(assetName) && uiManager.HasUIForm(assetName);","typeGuard":"bool IsValidAssetName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":"try { exists = uiManager.HasUIForm(assetName); }\ncatch (GameFrameworkException) { exists = false; }","preventionTips":["Store form asset names in a constants class shared with OpenUIForm call sites","Validate inspector/config strings for empty values at load time","Check names after resource-renaming refactors"],"tags":["empty-string","ui","asset-name"],"backgroundTag":"empty-required-field","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"}