EllanJiang/GameFramework · error · GameFrameworkException
Can not find entity ' '.
Error message
Can not find entity '{0}'. What it means
HideEntity(entityId) looks up the EntityInfo for the given id. If no shown entity with that id exists, GetEntityInfo returns null and this exception is thrown. You can only hide entities that were successfully shown and not yet hidden.
Solutions
- Check HasEntity(entityId) before calling HideEntity
- Track shown entity ids and only hide ids you know are alive
- Hide via the IEntity reference you received in ShowEntitySuccess instead of a cached id
Example fix
// before
m_EntityComponent.HideEntity(id, null); // id may be stale
// after
if (m_EntityComponent.HasEntity(id))
{
m_EntityComponent.HideEntity(id, null);
} Defensive patterns
Strategy: validation
Validate before calling
if (!entityManager.HasEntity(entityId)) return;
Type guard
bool IsHideable(int id) => entityManager.HasEntity(id);
Try / catch
try { HideEntity(id, userData); } catch (GameFrameworkException ex) when (ex.Message.Contains("Can not find entity")) { Debug.LogWarning($"Entity {id} already hidden"); } Prevention
- Remove ids from your tracking set on HideEntitySuccess
- Avoid hiding entities whose show has not succeeded yet
- Prefer hiding via IEntity references you hold
When it happens
Trigger: Calling HideEntity with an id never shown, an id already hidden, or an id whose show is still loading (not yet registered).
Common situations: Hiding on scene unload with stale ids; double-hide from overlapping teardown paths; hiding an entity whose show failed asynchronously; serial id mismatch after reload.
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
- Can not find child entity
- Can not find parent entity
- Entity group ' ' not exists specified entity '[ ] '.
- Can not remove child entity which is not exist.
- Entity id ' ' is already exist.
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/9061d732b7c87af2.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Entity/EntityManager.cs:684
/// <summary>
/// 隐藏实体。
/// </summary>
/// <param name="entityId">实体编号。</param>
/// <param name="userData">用户自定义数据。</param>
public void HideEntity(int entityId, object userData)
{
if (IsLoadingEntity(entityId))
{
m_EntitiesToReleaseOnLoad.Add(m_EntitiesBeingLoaded[entityId]);
m_EntitiesBeingLoaded.Remove(entityId);
return;
}
EntityInfo entityInfo = GetEntityInfo(entityId);
if (entityInfo == null)
{
throw new GameFrameworkException(Utility.Text.Format("Can not find entity '{0}'.", entityId));
}
InternalHideEntity(entityInfo, userData);
}
/// <summary>
/// 隐藏实体。
/// </summary>
/// <param name="entity">实体。</param>
public void HideEntity(IEntity entity)
{
HideEntity(entity, null);
}
/// <summary>
/// 隐藏实体。
/// </summary>
/// <param name="entity">实体。</param>View on GitHub (pinned to d0c010b051)