Why do some Components have enable/disable checkboxes in the Inspector while others don't?

Shouldn’t all and ever component have a check box where you could disable it?

1 Like

I might be wrong, but if you don’t have void Start(), in a script, it won’t have the check box you are referring to :).

-Ali

1 Like

Almost…It’s if if doesn’t have OnEnable()…in the script

A MonoBehaviour has a checkbox if it has any methods that care about the enabled property. These are, afaik:

Start
Update
FixedUpdate
LateUpdate
OnEnable
OnDisable

Of note, Awake, all of the physics methods (OnTriggerX, OnCollisionX), and all of the mouse methods (OnMouseEnter, Down, Drag, Exit, Over, etc.) will not create the checkbox. This is because they don’t care if the script is disabled, and will still get called.

It is completely counter-intuitive and really bad design that a disabled script will receive OnTriggerEnter, but that’s a discussion for another day.

EDIT: the .enabled property isn’t defined on Component, but on several subclasses of Component - like Behaviour and Collider. So there’s a lot of Components you can’t disable, like Rigidbodies and Joints. Why you can’t disable them is probably because it was deemed as not useful or meaningful to disable those components.

12 Likes