EllanJiang/GameFramework · error · GameFrameworkException
UI form asset name is invalid.
Error message
UI form asset name is invalid.
What it means
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.
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
Example fix
// before bool has = ui.HasUIForm(formName); // after bool has = !string.IsNullOrEmpty(formName) && ui.HasUIForm(formName);
Defensive patterns
Strategy: validation
Validate before calling
bool exists = !string.IsNullOrEmpty(assetName) && uiManager.HasUIForm(assetName);
Type guard
bool IsValidAssetName(string name) => !string.IsNullOrEmpty(name);
Try / catch
try { exists = uiManager.HasUIForm(assetName); }
catch (GameFrameworkException) { exists = false; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- UI group name is invalid.
- UI form asset name is invalid.
- UI group name is invalid.
- Entity group name is invalid.
- Old name is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/e707c8d1b1deb0ce.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/UI/UIManager.cs:419
if (uiGroup.Value.HasUIForm(serialId))
{
return true;
}
}
return false;
}
/// <summary>
/// 是否存在界面。
/// </summary>
/// <param name="uiFormAssetName">界面资源名称。</param>
/// <returns>是否存在界面。</returns>
public bool HasUIForm(string uiFormAssetName)
{
if (string.IsNullOrEmpty(uiFormAssetName))
{
throw new GameFrameworkException("UI form asset name is invalid.");
}
foreach (KeyValuePair<string, UIGroup> uiGroup in m_UIGroups)
{
if (uiGroup.Value.HasUIForm(uiFormAssetName))
{
return true;
}
}
return false;
}
/// <summary>
/// 获取界面。
/// </summary>
/// <param name="serialId">界面序列编号。</param>
/// <returns>要获取的界面。</returns>View on GitHub (pinned to d0c010b051)