Do un-active game objects still use memory?

My title is a little vague, so let me explain…

I created an ramp with some “addons” attached to it in my 3D program. The ramp is the parent, then it has some arrows pointing in the direction you need to go as a child, and a support beam underneath as another child. The whole thing is exported as a single FBX file, but not collapsed so I can access the children individually in Unity.

I wrote a small script that is attached to the GameObject, which lets me assign the arrows and the support beam as “addons”, and makes it possible to “deactivate” or “activate” those “addons” to make them visible or invisible.

They key word here is “activate”, as in = false/true. It does’t destroy or instantiate the addons game objects, it just hides them. My question is, since the “addons” are not being destroyed but just hidden, is my object just as expensive with the addons invisible then with them visible? Do I need to “destroy” and “instantiate” them if I want to save memory and speed?

Thanks in advance for any clarification on this, and thanks for your time!

I am currently wondering about this very same question, but can’t seem to find a straight answer anywhere.

So far what I’ve gathered is that when you use the toggle, none of the components on that gameObject will receive any updates. That means that you are saving performance in the sense that the inactive object is not considered at runtime, before it is activated. The object DOES exist in memory though when using this approach.

When using Instantiate and Destroy, the object is not present in memory before it is instantiated. While that means saving memory usage, instantiating the object seems to be a more expensive process than activating an inactive object. Especially if it’s a complex object, you will likely take up some performance when instantiating.

To answer your question, then: No, your objects are not as expensive when they are hidden ( = false), than if they are visible ( = true). This is because the components within the object are not receiving any updates from Update, FixedUpdate or LateUpdate, and of course the fact that it’s not being rendered.

If you want to save memory per se, then yes – you will have to use Instantiate/Destroy.