Spawning Objects Into Unity Without The Clutter

When you instantiate a game object into a scene within unity it will appear as a new object within the hierarchy. This can prove to be annoying as new objects continue to spawn and clutter up the window…

So what should I do?

It’s easy! The simplest way to go about correcting this is to create an empty game object in the hierarchy and use it as a storage container from which to assign all newly instantiated objects as children. The code below shows how to implement this.

[NOTE]

You will need to drag and drop the prefab you are wanting to spawn into the game object reference “_enemy” within the hierarchy. The empty game object that will be used as a storage container will need to be referenced as well. Drag and drop that object into the game object reference _enemyContainer within the hierarchy.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Reed

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!