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.

--

--

--

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!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

CS373 Fall 2020 : Elias Lampietti [Final Entry]

CSS Basic: Background

Links on erlang/elixir, and their story in brief

Hidden cost of String allocation in Swift

Chrome’s Experimental Image Lazy Loading Flag

TryHackMe: Biohazard Writeup

Future Of Web Development — Trends For 2021 And Beyond

CSS Animation: keyframes

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!

More from Medium

Zoo Cards as Scriptable Objects

Journal 144 — Unity Project Development, 2.5D Shooter

Making a Hack’n’slash #7: Using Scriptable Objects and Prefabs

OnCollisionEnter Vs. OnTriggerEnter — When to use them?