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.
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
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!
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!