EllanJiang/GameFramework · error · GameFrameworkException

Can not remove child entity which is not exist.

Error message

Can not remove child entity which is not exist.

What it means

RemoveChildEntity removes a child entity from the entity's child list and throws GameFrameworkException if List.Remove returns false, i.e. the child is not attached to this entity. Called by DetachEntity when detaching an entity that is not actually a child of the given parent.

Solutions

  1. Verify the child is currently attached to this parent before detaching (GetParentEntity check).
  2. Make detach/cleanup idempotent with an existence check.
  3. Catch GameFrameworkException in bulk teardown loops and continue.
  4. Fix ordering so hide/detach logic runs only once per entity.

Example fix

// before
entityManager.DetachEntity(childId, parentId); // throws if not a child
// after
if (entityManager.GetParentEntity(childId) == parentId)
{
    entityManager.DetachEntity(childId, parentId);
}
Defensive patterns

Strategy: validation

Validate before calling

if (entityManager.GetParentEntity(childId) != parentId) return;
entityManager.DetachEntity(childId, parentId);

Try / catch

try { entityManager.DetachEntity(childId, parentId); }
catch (GameFrameworkException ex) { Log.Warning("Skip detach, not a child: {0}", ex.Message); }

Prevention

When it happens

Trigger: Calling DetachEntity for an entity whose parent is a different entity or null; detaching twice; stale parent references after hierarchy changes.

Common situations: Teardown code detaching all entities from a parent that was already cleared; wrong parent id passed to DetachEntity; concurrent hide/detach removing the child before your detach runs.

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


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

Appendix: source

Thrown at GameFramework/Entity/EntityManager.EntityInfo.cs:131

                    results.Add(childEntity);
                }
            }

            public void AddChildEntity(IEntity childEntity)
            {
                if (m_ChildEntities.Contains(childEntity))
                {
                    throw new GameFrameworkException("Can not add child entity which is already exist.");
                }

                m_ChildEntities.Add(childEntity);
            }

            public void RemoveChildEntity(IEntity childEntity)
            {
                if (!m_ChildEntities.Remove(childEntity))
                {
                    throw new GameFrameworkException("Can not remove child entity which is not exist.");
                }
            }
        }
    }
}

View on GitHub (pinned to d0c010b051)