What is the difference between these three ways of making an object disappear?


These three are each make the object disappear from the scene. What is the difference between them?

EDIT: for clarity

#For InvokeRepeating…

#1) disable whole game object - InvokeRepeating does NOT stop

#2) disable just the script component - InvokeRepeating does NOT stop

#For coroutines…

#3) disable whole game object - coroutine >>> DOES <<< stop

#4) disable just the script component - coroutine does NOT stop

#In all four cases, the repeat is “eliminated”, it is NOT paused. If you again SetActive(true), in all four cases, the repeat does NOT continue where it left off.

#Simply use OnDisble() and the similar routines if you want custom behaviour on disabling.

Behaviour.enabled and Renderer.enabled stop an attached Renderer or Behaviour (MonoBehaviour and number of other components) from running their update code. In the case of Renderers, it stops them from showing. You can turn this variable on and off from code or use the checkbox next to the Behaviour in the Inspector. Note that not all Components are Behaviours or Renderers, so (for instance) Colliders can't be disabled.

GameObject.active is like enabled, but for all Components on a GameObject. Instead of just stopping Update() and rendering callbacks, it stops all callbacks and coroutines. GameObject.active is the only way to turn off attached Colliders. You can turn this variable on and off from code or by using the checkbox at the top of the GameObject inspector.

Object.Destroy() causes the permanent deletion of its target. This can be a Behaviour, Component, GameObject, or anything else that inherits from Object. If you destroy a GameObject, all of its attached Components will also be destroyed. Destroy() is the same as selecting something in the Hierarchy and deleting it. Destroy() is irreversible.

GameObject.Destroy(gameObject) delete the game object, gameObject.active=false disable the game object and all of its components, gameObject.renderer.enabled=false disable only the renderer so you can't see the object but all of its components do work.

it would be nice to know more specifically what changing Renderer.enabled does. For some reason, toggling GameObject.enabled back and forth can take a LOT of time; no very good explanation is given in the docs where the time is wasted at.

For instance, what kind of CPU/GPU traffic should I expect from toggling Renderer.enabled? Will VBOs be re-uploaded every time? Are collisions enabled when renderer is disabled? What about skinning calculations?