EllanJiang/GameFramework · error · GameFrameworkException

Entity ' ' is already being loaded.

Error message

Entity '{0}' is already being loaded.

What it means

EntityManager tracks entities currently being asynchronously loaded. If ShowEntity is called with an entityId whose asset load is still in flight, IsLoadingEntity returns true and this exception is thrown, preventing a double load for the same id.

Solutions

  1. Guard with IsLoadingEntity(entityId) before calling ShowEntity again
  2. Debounce/duplicate-suppress the UI event that triggers ShowEntity
  3. Queue the second request and apply it in the ShowEntitySuccess callback instead of re-calling

Example fix

// before
m_EntityComponent.ShowEntity(id, "Player", "PlayerGroup", null); // may double-fire
// after
if (!m_EntityComponent.IsLoadingEntity(id) && !m_EntityComponent.HasEntity(id))
{
    m_EntityComponent.ShowEntity(id, "Player", "PlayerGroup", null);
}
Defensive patterns

Strategy: validation

Validate before calling

if (entityManager.IsLoadingEntity(entityId) || entityManager.HasEntity(entityId)) return;

Type guard

bool IsLoadable(int id) => !entityManager.IsLoadingEntity(id);

Try / catch

try { ShowEntity(id, asset, group, userData); } catch (GameFrameworkException ex) when (ex.Message.Contains("already being loaded")) { Debug.LogWarning($"Entity {id} load in progress"); }

Prevention

When it happens

Trigger: Calling ShowEntity again with an entityId whose previous ShowEntity call has not yet completed its asset load (LoadAsset success callback not yet fired).

Common situations: User clicks a spawn button twice before the async load finishes; retry logic re-issuing ShowEntity on a slow load; UI event fired multiple times while a prefab loads from disk or network.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of EllanJiang/GameFramework@d0c010b051 (2026-09-15). Data as JSON: /api/errors/96b1f56205cc201b. Report an issue: GitHub.

Appendix: source

Thrown at GameFramework/Entity/EntityManager.cs:637

            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);
                m_ResourceManager.LoadAsset(entityAssetName, priority, m_LoadAssetCallbacks, ShowEntityInfo.Create(serialId, entityId, entityGroup, userData));
                return;
            }

            InternalShowEntity(entityId, entityAssetName, entityGroup, entityInstanceObject.Target, false, 0f, userData);

View on GitHub (pinned to d0c010b051)