Spawning Objects in Unity without the Clutter

This is a quick follow-up to my last article on coroutines just to show how I declutter my hierarchy when instantiating enemies with my SpawnManager.
First I created an empty gameobject and named it Enemy_Container.

Now in my SpawnManager script I created a private Transform variable named _enemyContainer and serialized the field.

Now I click my Spawn_Manager and drag the Enemy_Container gameobject into my serialized field on the SpawnManager script.

In my SpawnManager script after instantiating the newEnemy in my SpawnRoutine coroutine I add a line that sets this newEnemy’s transform parent to be the enemyContainer


Now when enemies are spawned they go directly inside the Enemy_Container in the hierarchy instead of cluttering it up.
