- Home /
performance between disable renderer and disable gameObject
Is there a performance difference between disabling an object's renderer and disabling the gameObject itself?
The problem with using gameObject.active = false is that my script can't find it anymore, so I was thinking of doing gameObject.renderer.enabled = false, but if I do that, will the gameObject still be computed by the engine?
Stephane
Yes, if you set the renderer to false it will only make the object invisible everything else will function as normal.
Answer by dannyskim · Feb 17, 2012 at 05:26 PM
Yes, turning the renderer off still causes the engine to make computations on it, for example physics.
Answer by jonc113 · Apr 17, 2013 at 03:41 PM
gameObject.active has been replaced by SetActiveRecursively
see: http://answers.unity3d.com/questions/36259/how-to-deactivate-a-parent-and-its-children.html
gameObject.active
was replaced by `GameObject.SetActive` which is way more efficient. You can then deter$$anonymous$$e whether an object is active based upon itself `GameObject.activeSelf` or based upon its parent hierarchy with `GameObject.activeInHeirarchy`.
So, gameObject.active was replaced by SetActiveRecursively which was replaced by SetActive? $$anonymous$$y Functions come and go so quickly here. I gotta keep up with the times!
Both GameObject.active
and GameObject.SetActiveRecursively
became deprecated since Unity 4. For more information please refer to the following: http://docs.unity3d.com/Documentation/$$anonymous$$anual/UpgradeGuide3540.html
Your answer
Follow this Question
Related Questions
Does inactive Objects eat up Performance? 1 Answer
Renderer disabled = Any good? 1 Answer
large number of identical objects in scene? 3 Answers
Replace GameObject vs. replacing mesh and material? 2 Answers