EllanJiang/GameFramework · error · GameFrameworkException
Can not find UI form
Error message
Can not find UI form '{0}'. What it means
CloseUIForm(int serialId) resolves the serial ID to an open UI form via GetUIForm; when no form with that serial ID exists (never opened, already closed, or loaded from a stale id), the framework throws this formatted GameFrameworkException including the id.
Solutions
- Check existence before closing: if (uiManager.GetUIForm(serialId) != null) uiManager.CloseUIForm(serialId);
- Track form validity: set the stored id to 0/invalid after CloseUIForm succeeds to prevent double-close
- Use IsAvailableUIFormSerialId / HasUIForm checks if exposed by your framework version
- Catch GameFrameworkException around close calls driven by external events
Example fix
// before
uiManager.CloseUIForm(m_MenuSerialId); // may already be closed
// after
if (uiManager.GetUIForm(m_MenuSerialId) != null)
{
uiManager.CloseUIForm(m_MenuSerialId);
m_MenuSerialId = 0;
} Defensive patterns
Strategy: validation
Validate before calling
if (serialId <= 0 || uiManager.GetUIForm(serialId) == null)
{
Log.Warn($"Skipping CloseUIForm: no open form with id {serialId}");
return;
} Type guard
bool FormIsOpen(UIManager m, int serialId) => serialId > 0 && m.GetUIForm(serialId) != null;
Try / catch
try { uiManager.CloseUIForm(serialId); }
catch (GameFrameworkException ex) when (ex.Message.Contains("Can not find UI form"))
{ Log.Warn($"Stale UI form id {serialId}"); } Prevention
- Invalidate stored serial ids (set to 0) immediately after closing
- Guard close-all/close logic against double invocation with a flag
- Never persist serial ids across scene changes; re-resolve forms after transitions
When it happens
Trigger: Calling CloseUIForm with a serialId that does not correspond to any currently open UI form — e.g. closing twice, closing a form that failed to load, or using a saved/stale serial id across scenes.
Common situations: Double-close on the same event, close-all triggered while a form's open callback had not yet finished, storing serial ids that become invalid after scene switches, or off-by-one around the ++m_Serial id generation.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- UI group ' ' is not exist.
- appendErrorMessage
- Can not create UI form in UI form helper.
- Can not find sound ' '.
- Can not find UI form info.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/5a211214f0efbd28.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/UI/UIManager.cs:792
/// <summary>
/// 关闭界面。
/// </summary>
/// <param name="serialId">要关闭界面的序列编号。</param>
/// <param name="userData">用户自定义数据。</param>
public void CloseUIForm(int serialId, object userData)
{
if (IsLoadingUIForm(serialId))
{
m_UIFormsToReleaseOnLoad.Add(serialId);
m_UIFormsBeingLoaded.Remove(serialId);
return;
}
IUIForm uiForm = GetUIForm(serialId);
if (uiForm == null)
{
throw new GameFrameworkException(Utility.Text.Format("Can not find UI form '{0}'.", serialId));
}
CloseUIForm(uiForm, userData);
}
/// <summary>
/// 关闭界面。
/// </summary>
/// <param name="uiForm">要关闭的界面。</param>
public void CloseUIForm(IUIForm uiForm)
{
CloseUIForm(uiForm, null);
}
/// <summary>
/// 关闭界面。
/// </summary>
/// <param name="uiForm">要关闭的界面。</param>View on GitHub (pinned to d0c010b051)