MixedRealityToolkit / MixedRealityToolkit-Unity

This repository holds the third generation of the Mixed Reality Toolkit for Unity. The latest version of the MRTK can be found here.
BSD 3-Clause "New" or "Revised" License
411 stars 111 forks source link

Recommended approach for disabling all interactions in a MRTK enabled UI Canvas #951

Open TheXRMonk opened 1 month ago

TheXRMonk commented 1 month ago

Describe the issue

Let's say we have a couple of pages swiping from left to right. The PressableButton together with the RectTransformColliderFitter will nicely shorten the box collider as a page transitions across the "screen" and outside the "UI Mask", meaning you can't click buttons that are off screen. Great! However, how does one disable the buttons while they are transitioning? We want to block users from accidentally pressing buttons that are going off or coming onto the screen.

There's no clear way to do this.

In native unity UI you would just disable the Graphics Raycaster or put an invisible component over the screen to block raycasts, but there's no way to do this in MRTK.

What we've tried so far:

So main question: How should one turn off a whole "canvas" of MRTK UI?

Feature area

MRTK Canvas UI

AMollis commented 1 week ago

@ghazen-ml can you please add your recommendations to this issue?

AMollis commented 1 week ago

@TheXRMonk can you please describe the end user impact of this issue? What issue are you hitting "while buttons are transitioning"?

ghazen-ml commented 1 week ago

A few tricks that could be useful for situations like this:

  1. Adjust the raycast mask for the XRRayInteractor while you would like to disable input, e.g. to remove a particular layer and then re-add it afterwards
  2. Add a temporary large collider to capture raycasts before they hit a particular panel (this may not work well if the user would be very close to the panel)
  3. Switch the layers of the interactables in question so they are temporarily not targetable by the interactor raycasts.

It would be great to understand more about your use case -- why are users attempting to click while a view is paging? Did their interaction cause the transition or is it happening automatically or on a timer?

TheXRMonk commented 6 days ago

A few tricks that could be useful for situations like this:

  1. Adjust the raycast mask for the XRRayInteractor while you would like to disable input, e.g. to remove a particular layer and then re-add it afterwards
  2. Add a temporary large collider to capture raycasts before they hit a particular panel (this may not work well if the user would be very close to the panel)
  3. Switch the layers of the interactables in question so they are temporarily not targetable by the interactor raycasts.

We're only using near interactions - no rays. Not sure point 3 will solve it, but that might be possible,

It would be great to understand more about your use case -- why are users attempting to click while a view is paging? Did their interaction cause the transition or is it happening automatically or on a timer?

Basically when a user clicks "next" the page transitions a whole page. While this is happening the user's finger might be accidentally clicking buttons that are "transitioning" across the screen, leading to the UI reacting to for instance going back again to the previous page, or fast forwarding to the next one before the user has even seen/read it.