What does 'enabled' do in isolation within a script?


In the MachineGun script from the Unity FPS tutorial is this line:

enabled = false;

I looked in the script reference and found this:

"Behaviour.enabled Enabled Behaviours are Updated, disabled Behaviours are not."

Does this mean that the Update(), FixedUpdate() and LateUpdate() functions are not called within only the script in which that line appears? Or, as Behavior is a super-class, is it affecting other scripts attached to the parent object?


It affect only the instance. If a game object have several behaviors, disabling one will not affect the others. If you have a script and write enabled = false; it will only disable the script that is running. Other scripts will remain enabled. To disable another script, you should set enable on that particular instance instead. renderer.enabled = false; for example turns off the renderer.

There is also gameObject.active which disable the game object and any components attached to it.