Skip to content

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

Closed
@TheXRMonk

Description

@TheXRMonk

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:

  • Turn off the colliders on the buttons, but there seems to be a single physics update frame where the buttons are still active (so you can quickly click two buttons (navigate left and navigate right) on the same screen even though both button colliders are disabled as soon as one of the OnClick events are fired).
  • Turn off the button. This kinda works, but for some reason MRTK has decided that component.enabled = button.interactable, so not only does the visual appearance of the buttons change, but now we also have to manually save and restore the "previous" interactable state of the button, which quickly becomes a nightmare.

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

Feature area

MRTK Canvas UI

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Author AttentionNeeds additional information from the issue authorNeeds: TriageNeeds to be triaged.Type: DocumentationIssue for new or existing documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions