Component disabled, but still receiving Collision messages?

Hi there, I have a component disabled at run time (which I activate when needed). However, I’m noticing that it’s still receiving OnTrigger() messages while it’s disabled - is this behavior expected?


Yes, this is how it works. What you could do is check if the script is enabled in your OnTrigger function like so:

void OnTriggerEnter( Collider collider )
    if ( !this.enabled ) return;

    // this code wont be called if the script is disabled.