- Home /
What's the difference between activate/deactivate & enable/disable game objects?
It looks like there's little difference between activate/deactivate & enable/disable for game objects. So I wonder what's the difference between them? What's the "best practice" of using these different methods? Any examples can show the difference is appreciated.
Answer by zombience · Sep 05, 2014 at 05:23 AM
Activated / Deactivated game objects are just that: they are either activated in the scene or not. Deactivating a gameobject stops any Update() methods from being called on any monobehaviour components attached to your game object. you activate/deactivate a game object through the builtin method: SetActive(trueOrFalse)
enable / disable is specifically for components, such as colliders or your monbehaviour scripts. You can activate/deactivate any component on a game object, and then only that component will be disabled. so, if you want one script in particular to stop executing its Update() method, you can disable that script. note that even though a script is disabled, you can still call other functions and access variables, etc. the script is still accessible, but the Update() method is no longer called automatically once per frame.
hope that helps
Are there any differences on performance if you activate/deactivate a gameobject with SetActive or a component with enabled?
Well, yes - gameobjects can have many different components; typically a renderer, a collider, a transform, perhaps a mesh filter, + any number of custom scripts. If you set one of those components to disabled, all the rest continue to operate. If you deactivate the gameobject, however, all of its components will cease to operate.
small typo: "You can activate/deactivate any component on a game object" should be changed to " You can enable/disable any component on a game object" for better understanding!
Your answer
![](https://koobas.hobune.stream/wayback/20220613162332im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is there any command that can reference deactivated objects? 1 Answer
How Do i Enable an Object and then Disable it? 1 Answer
enable / disable a script without dynamic typing 2 Answers
Rigidbody velocity limiter 0 Answers
Enable/Disable AI script 1 Answer