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?
Thanks!
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?
Thanks!
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.
}