'How to convert a standard Unity Canvas so that the buttons can receive inputs via the Hololens 2?

I am currently working with the MRTK on Unity and try to set up and interactible menu for the Hololens 2.

I have a canvas with multiple pressable buttons on it (pressing a button opens a new canvas).

I designed the UI with normal objects. Now I installed the mrtk to interact with the canvas on the HL2. My Problem is: The buttons on the canvas receive the hover (they change the color) but they dont receive touching events. I then used the HL2 prefab buttons and put all the scripts on there on my standard buttons. Now they act like I want it to but it is a lot of work to do that for every single button.

I know that for VR on Unity there is a simple solution where the OnClick() Methods from buttons easily can be triggered with the VR Headset Input from the hands by adding a module to the Eventsystem.

Is there something equally easy workaround for AR? I read about the Holo ToolKit but this does not exist anymore.

Thank you so much for your help !

EDIT:Scripts attached to the normal UnityUI Button



Solution 1:[1]

To make the buttons under the Unity Canvas work on the HoloLens, please follow these steps:

  1. Select Canvas object in your scene, then in the Inspector panel for your Canvas, click "Convert to MRTK Canvas"
  2. Click "Add NearInteractionTouchableUnityUI"
  3. Set the Rect Transform component's X, Y, and Z scale to 0.001
  4. Add the Interactable component to your button and assign OnClick Event for this Interactable component.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hernando - MSFT