Should Physics.Raycast() hit a Trigger on a disabled GameObject?

Hi There

I have many UIs that occupy the same space on the screen and are hidden and shown as the game requires. Each button contains a collider (set to trigger) for that button and mouse/touch interaction is done via Physics.Raycast(). The problem I have is that when I am trying to click certain buttons that are visible, the Physics.Raycast() returns the Collider for a button who’s GameObject is inactive. The UI is all in one hierarchy, the root of which contains a kinematic RigidBody with gravity off. If I remove this RigidBody, the ‘hidden’ colliders are no longer hit by the Raycast and it all works.

The docs are a little woolly on this - it says raycast is performed against all colliders (and presumably triggers) in the scene, and naturally there’s the option to rayacst only against certain layers. It isn’t explicit about behaviour against colliders on inactive GameObjects. I would however, have thought that the raycast would remain the same regardless of the RigidBody, unless the RigidBody has some intentional side-effect I am unaware of?

So what should the behaiour be? If the RigidBody is altering the behaviour, is this as expected? If so, can someone explain it, if not, can you post the link to log a bug :oD

I am using nGUI and have sought some guidance on the nGUI forums, but this feels more like a Unity issue? I am on the latest (3.6.6) Unity (Pro) and the latest nGUI. I have tried to re-create the issue in a smaller scene with no success as yet.

Thanks in advance.
Bovine

That does sound like a bug - changing the RigidBody state changes the registration of the object with PhysX, but if a GameObject is inactive all of its components are inactive as well. Just curious - after the RigidBody has been registered with physics (e.g. after the Awake/Start function if you’re adding in the editor, or a frame after you’ve added it at runtime), what happens if you turn on the deactivated trigger GOs and then turn them back off? Do they behave properly, or are they stuck in this mode?

You should definitely file a bug report - you can access it from the Help menu within the Unity Editor, and attach your project or specific files to the report.