Organize a level and prefab dependencies
Who creates objects, owns state and disconnects handlers; a testable structure instead of fragile deep paths.
Separate responsibilities
Keep a scenario controller and meaningful containers at the level root: world, interface and local effects. A character prefab owns its visual/physics parts. Put a shared session outside the replaced root only when it needs to survive deletion.
This is an Entity object hierarchy. Container names neither turn it into ECS nor add streaming. Child count alone is not a performance measurement.
| Question | Assign responsibility |
|---|---|
| Who creates and deletes an enemy? | The level controller or an explicit spawner |
| Who mutates health? | A health component with a restricted API |
| Who listens for death? | The external controller needing that event |
| Who displays session score? | A HUD with a subscription and initial snapshot |
| Who frees a detached room? | The host/cache retaining it |
Supply dependencies instead of guessing surroundings
A stable internal child path is reasonable when the prefab owns that structure. Inject an external target reference or data before AddChild. Use a signal to report intent; the emitter need not search for a particular level parent.
%Name helps within an Owner scope rather than globally discovering services. /root/SessionState is an explicit autoload contract, not a path pattern to copy into every local component.
Distinguish three ownership meanings
Parent defines hierarchy and child deletion when the parent is freed. Owner identifies membership in a saved PackedEntity. Responsibility for gameplay operations is your architecture decision rather than another Entity property.
RemoveChild leaves the native object alive. RetainedLevelHost explicitly owns detached roots and frees inactive rooms on exit. Merely removing Parent and forgetting an object removes its parent-tree deletion guarantee.
Verify before growing the project
Run a prefab alone, create two instances, delete one, move an internal child, change levels and reattach a detached interface. Verify the second instance does not depend on first-instance fields, an external signal does not retain a removed HUD, and _Ready is not the only reentry subscription mechanism.
Executable examples are the group component, session/HUD, lifecycle and Owner-scoped lookup. Checks bind these boundaries to real objects rather than only a folder diagram.