OnMouseOver being called even when component is disabled

I have a script on an object that is enabled only when interacting with a specific object (in this case, the lock component for a door, which is only enabled once the key is picked up), but the script’s OnMouseOver function is throwing errors when the player looks at it, despite the component being disabled.

I have tried numerous things to prevent this but have gotten nowhere.

I am using the standard setup, using void OnMouseOver(), nothing else is calling it and I have no fancy code behind anything else that is using it, is there an alternative to OnMouseOver that doesn’t fire when the component is disabled?

OnMouseOver is part of MonoBehaviour. This means that OnMouseOver is being called regardless of whether the parent object is enabled or not. Short of implementing a raycast test in Update() the only thing I could offer would be to test the enabled status before doing anything when OnMouseOver is called.