EllanJiang/GameFramework · error · GameFrameworkException
Entity id ' ' is already exist.
Error message
Entity id '{0}' is already exist. What it means
EntityManager.ShowEntity enforces that each entity id is unique while shown. If HasEntity(entityId) is true, the id is already in use by a live entity, so it throws. Entity ids are caller-supplied serial numbers and must not collide.
Solutions
- Use a strictly increasing unique serial id generator (e.g., m_Serial++) per show call
- Hide the existing entity with that id before re-showing it
- Check HasEntity(entityId) before calling ShowEntity and skip or error out gracefully
Example fix
// before
int id = 1001;
m_EntityComponent.ShowEntity(id, "Player", "PlayerGroup", null); // called twice
// after
if (!m_EntityComponent.HasEntity(id))
{
m_EntityComponent.ShowEntity(id, "Player", "PlayerGroup", null);
} Defensive patterns
Strategy: validation
Validate before calling
if (entityManager.HasEntity(entityId)) return; // already shown
Type guard
bool CanShow(int id) => !entityManager.HasEntity(id) && !entityManager.IsLoadingEntity(id);
Try / catch
try { ShowEntity(id, asset, group, userData); } catch (GameFrameworkException ex) when (ex.Message.Contains("is already exist")) { Debug.LogWarning($"Entity {id} already shown, skipping"); } Prevention
- Use a single central serial id generator
- Never reset id counters mid-session
- Check HasEntity before every ShowEntity
When it happens
Trigger: Calling ShowEntity with an entityId that already belongs to an existing (not yet hidden) entity.
Common situations: Reusing serial id counters after domain reload; showing the same logical entity twice (e.g., double click spawning a unit); restoring a scene without hiding previous entities; serial id generator reset.
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
- Entity ' ' is already being loaded.
- Entity group ' ' is not exist.
- Can not find entity ' '.
- Entity is invalid.
- Can not find child entity
AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15).
Data as JSON: /api/errors/4afcf5e06f840c29.
Report an issue: GitHub.
Appendix: source
Thrown at GameFramework/Entity/EntityManager.cs:632
if (m_EntityHelper == null)
{
throw new GameFrameworkException("You must set entity helper first.");
}
if (string.IsNullOrEmpty(entityAssetName))
{
throw new GameFrameworkException("Entity asset name is invalid.");
}
if (string.IsNullOrEmpty(entityGroupName))
{
throw new GameFrameworkException("Entity group name is invalid.");
}
if (HasEntity(entityId))
{
throw new GameFrameworkException(Utility.Text.Format("Entity id '{0}' is already exist.", entityId));
}
if (IsLoadingEntity(entityId))
{
throw new GameFrameworkException(Utility.Text.Format("Entity '{0}' is already being loaded.", entityId));
}
EntityGroup entityGroup = (EntityGroup)GetEntityGroup(entityGroupName);
if (entityGroup == null)
{
throw new GameFrameworkException(Utility.Text.Format("Entity group '{0}' is not exist.", entityGroupName));
}
EntityInstanceObject entityInstanceObject = entityGroup.SpawnEntityInstanceObject(entityAssetName);
if (entityInstanceObject == null)
{
int serialId = ++m_Serial;
m_EntitiesBeingLoaded.Add(entityId, serialId);View on GitHub (pinned to d0c010b051)