- Home /
How resources-consuming are disabled things? How much drain puts enable/disable components/GOs on the system?
I asked this question before, but since I had a practical issue mixed in, I only got a solution for this particular problem but not a general answer. But I'm still interested and this question reminded me to go back to my initial inquiry... the >1.6k hits show, that I'm probably not the only one curious...
How much resources are consumed by disabled GameObjects?
How much resources are consumed by disabled Components?
How much strain does enable/disable of GameObjects put on the system?
How much strain does enable/disable of Components put on the system?
Greetz, Ky.
Answer by SilverTabby · Jul 23, 2011 at 10:59 PM
I don't have access to the Unity source code on enabling/disabling objects so I am not a true expert on the subject, but this is my experience from working with Unity:
Almost no CPU resources are spent on inactive GameObjects.
Almost no CPU resources are spent on disabled components.
Very minimal amount of effort is required by the cpu to activate and deactivate GameObjects.
Very minimal amount of effort is required by the cpu to enable and disable Components.
The only overhead a disabled Component or inactive GameObject has is RAM usage, which is not a problem on most modern machines. Besides, it was already using that amount of RAM when it was enabled anyways.
The reason for this is because a script will only use CPU time when a function is called or a value is changed. Disabling a script makes it so that Update and similar functions are not called. No functions are executed, therefore no CPU time is used.
An inactive GameObject works the same way: it only uses CPU time when a value is changed (such as it's transform position), a function on a script attached to it is called, physics and collisions need to be checked, or it needs to be rendered. None of these things happen when the GameObject is inactive.
Also, Unity Pro has a feature that allows you to check cpu, memory, and gpu usage of everything in your scene. I'm too cheap to buy anything more expensive than the occasional pizza so I don't have specific numbers for you :(
Thank you very much =) This already helps a lot. accept
If anyone happens to have the smallchange and sparetime to check for numbers, that would be awesome though... =)
Greetz, $$anonymous$$y.
How does RA$$anonymous$$ relate to mobile devices? The way i understand it it is always better to remove/init gameobjects when developing for mobile devices. Is this assumption correct?
PixelPoolNL I have probed that you NEED to remove the gameobjects in a development for mobile devices cause it drains all the RA$$anonymous$$, specially textures of 3D models.
Answer by BTables · Aug 05, 2015 at 04:10 AM
SilverTabby's answer is only partially true. Disabled gameobjects cause a massive amount of CPU time if the parent of the transform is moved as unity still seems to need to calculate each transforms position in space regardless of whether it is active or not.
I'd also disagree with the claim that activating and deactivating GameObject's uses "very $$anonymous$$imal" CPU. It can actually be fairly intensive.
To expand on this excellent answer, GameObjects only stop using their $$anonymous$$onoBehaviors. All other callbacks to that class/object (including transform change like suggested by Nition) along with events and other such things will still consume resources.
Your answer
Follow this Question
Related Questions
Disable objects around the player? 2 Answers
Disable objects far away from player to make performance better 2 Answers
Performance Question, Change Boolean or Enable-Disable Script 0 Answers
Toggling a script on/off using the keyboard? 2 Answers
Why did my render time increase after lowering the vertex count? 2 Answers