- Home /
Does inactive Objects eat up Performance?
Does inactive objects still being processed by the CPU? Also how about in memory? Are inactive objects cleared in memory?
Answer by Diet-Chugg · May 25, 2013 at 07:42 AM
Inactive objects will take up memory. They are stored there so they can quickly be activated using the GameObject class's function .SetActive(bool active). This is nice to avoid having to call Instantiate (Transform.Instantiate()) to make a new object because that takes lots of CPU power. (SetActive takes CPU power too but not as much)
They can also eat up lots of CPU but typically not a problem. I find they use more CPU if they are parented to active objects that are moving/rotating/scale. The inactive objects will have to move/rotate/scale as well which requires additional processing. Once again most of the time inactive objects are not as much a problem.
The best way to find out what's eating up performance is using the Profiler but it's a Pro Only feature. I highly recommend it however. I was able to get my game from 20fps with lots of spikes and long loading times to a game that runs 60 fps and no spikes by using it as a guide on where to optimize. With out it you are shooting in the dark because a poorly written script, too many physics call, to much rendering, running scripts that don't need to be ran can all affect your frame rate.
Thanks so much. Very well said and detailed explanation. I'll apply the best things possible. Thank you so much.
Your answer
Follow this Question
Related Questions
Disable/Enable Script or Add/Remove? 1 Answer
activate GameObject dont work 1 Answer
SetActive(true) not working 2 Answers
GameObject.setActive(bool) is not activating my gameObject 1 Answer