microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Button not clickable when within the bounds of a bounding box #8295

Closed pampas93 closed 8 months ago

pampas93 commented 4 years ago

Describe the bug

Pressable button doesn't work when it's placed inside a bounding box of another gameObject.

If I double the size of the box collider for this bounding box, and place the button well inside the boundingBox, then the button works fine. This bug is reproducible only when the button is close the face of the bounding box and inside it.

To reproduce

Steps to reproduce the behavior:

  1. Create a gameObject with a boxCollider, and use this to build the boundingbox/boundsControl
  2. Place a pressable button within the bounds of the bounding box
  3. This button is not clickable. But when I deactivate the bounding box, button works fine.

Expected behavior

Button should be working inside/outside the bounding box

Screenshots

buttonClick

Your setup (please complete the following information)

ModischFabrications commented 3 years ago

I currently have the same problem, did you find a solution? The workaround of increasing distance between button and bounds won't help with far interactions either.

CDiaz-MS commented 3 years ago

It looks like there could potentially be conflicting physics collisions between the collider on the bounds control object and the collider on the button.

A solution could be to move the bounds control object to the Ignore Raycast layer when the collider on the bounds control object is touched. Another option could be to disable the collider component on the bounds control object when the hand is close to the face of the bounds control object, this would enable raycast hits to reach the button inside.

pampas93 commented 3 years ago

That can be a workaround. @CDiaz-MS

Here's another thought. When the near pointer is within the bounds, we automatically disable the collider component? The only drawback which I see here is, if there's an Object manipulator attached as well, then that wouldn't work. (Maybe consider this as a feature req for bounds control?)

ModischFabrications commented 3 years ago

I'm positive that the problem is that the outer collider captures all pointer events, which is also visible by the indicator alignment. @CDiaz-MS This would fix near interaction, but far interaction by pointer would still be broken, if I understand you correctly.

My first thought for an ideal solution would remove the "template" collider for bounds control and leave only the ones used in the handles, leading to an empty, collider less space between them. But to be honest, I haven't looked into the inner working of MRTK enough to be qualified for an implementation.

My Use-Case is to have an object be rotatable by bounds control while still being clickable as an Interactable, without any overlap in onClick-Events.

My current workaround:
By experimentation I found out that moving the Interactable and it's collider to a child object and then re-using that collider for the bounds of the parent object I was able to get both working at the same time. Unfortunately, this reuse of colliders gives close to no clearance between object and handles, which separable colliders would have no problems with.

-- Update: After sleeping on it for a night I have came to a better solution. I am still using the interactable + collider in a child object, but I am using a separate collider for the bounds control that is disabled while starting. This seems to work fine for now with no collision on the outer collider while still having proper bounds handles.

stale[bot] commented 2 years ago

This issue has been marked as stale by an automated process because it has not had any recent activity. It will be automatically closed in 30 days if no further activity occurs. If this is still an issue please add a new comment with more recent details and repro steps.

IssueSyncBot commented 8 months ago

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!