EllanJiang/GameFramework · error · GameFrameworkException
UI form asset name is invalid.
Error message
UI form asset name is invalid.
What it means
UIGroup.HasUIForm validates its lookup key and throws when uiFormAssetName is null or empty. The method compares each form's asset name against this key, so a blank key cannot match and would only hide caller bugs.
Solutions
- Pass the full, non-empty asset name (e.g. "Assets/Game/UI/DialogForm.prefab") to HasUIForm.
- Check where the name comes from — fix empty config fields or unassigned fields before querying.
- Trim/validate the name at the call site.
Example fix
// before bool exists = UIComponent.HasUIForm(formAssetName); // empty // after bool exists = !string.IsNullOrEmpty(formAssetName) && UIComponent.HasUIForm(formAssetName);
Defensive patterns
Strategy: validation
Validate before calling
if (!string.IsNullOrEmpty(uiFormAssetName))
{
bool exists = UIComponent.HasUIForm(uiFormAssetName);
} Type guard
bool HasName(string s) => !string.IsNullOrEmpty(s);
Try / catch
try { exists = UIComponent.HasUIForm(name); }
catch (GameFrameworkException ex) { Log.Error(ex, "HasUIForm called with empty name"); } Prevention
- Guard dynamic asset-name construction before use
- Keep asset names in a central table with startup validation
- Return early when the name source is empty instead of querying
When it happens
Trigger: Calling UIGroup.HasUIForm (often via UIComponent.HasUIForm) with a null or empty asset-name string.
Common situations: Form asset name stored in a variable loaded from config that was empty; string concatenation produced an empty path; calling a validity check before actually choosing the asset to test.
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 is invalid.
- UI form helper is invalid.
- UI form is invalid.
- UI group helper is invalid.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/895f2b17a357cf2e.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/UI/UIManager.UIGroup.cs:188
if (uiFormInfo.UIForm.SerialId == 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 (UIFormInfo uiFormInfo in m_UIFormInfos)
{
if (uiFormInfo.UIForm.UIFormAssetName == uiFormAssetName)
{
return true;
}
}
return false;
}
/// <summary>
/// 从界面组中获取界面。
/// </summary>
/// <param name="serialId">界面序列编号。</param>
/// <returns>要获取的界面。</returns>View on GitHub (pinned to d0c010b051)