Spawning Objects in Unity without the Clutter
Day 14- Making 2D Space Shooter Game
When you are working with game where you need to spawn many objects continuously, your Hierarchy is going to be cluttered with all of these spawned gameobjects making it hard to navigate and debug.
As you can see, with all of these gameobjects spawning, all your space in your hierarchy is being cluttered with spawns and it is only going to increase more you add other spawnable objects.
So, to work around this issue, you are going to create a gameobject inside the Spawn_manager and inside that you are going to spawn all the enemy gameobjects.
First you need to create a gameobject which is going to hold all the spawns as its child.
Next, you are going to create a gameobject that will contain the information about your EnemySpawns gameobject
Then you are going to create a new GameObject variable which is going to hold the information about the spawned gameobject.
And finally, you are going to set the Instantiated gameobject’s parent as _enemyContainer(EnemySpawns).
Then go to unity and drag your EnemySpawns gameobject to your _enemyContainer variable in Spawn_Manager script.
You can see that all the enemy gameobjects are spawned as child of EnemySpawns and preventing your hierarchy from cluttering.
You can similarly divide and manage the clutter of spawns by using the same method on other spawns as well.