Clicking on button using Controller

Hello community,

I want to create a button in the UI that can be clicked using the Magic Leap controller. Here is what I did:

  1. I simply dragged the XR Rig package from the Magic Leap SDK package and checked that the references in the Game Controller are filled in the XR Controller (Action based). Here is the reference:
  2. Then, in the Hierarchy, I right-clicked -> XR -> UI Canvas.
  3. I placed a button inside the UI canvas and added a script for the click listener. This click listener prints a debug log when clicked.
    image

When I run this app in the simulator, and I click on the UI button using raycasting through the controller, the color of the ray changes from red to white, but no logs are being printed.

I saw this approach in every tutorials, but not working with Magic Leap.

Other Working Approach:

Another approach I followed was to add the Grab Interactable component and a collider to the buttons. Now it listens to the click, but it also becomes movable, which is not intended. Please help me solve this problem.

I found that the first approach I mentioned works on the actual device but not in the simulator.

This issue should be shared with the Customer Voice team. I understand that support for the simulator is no longer provided, but the Magic Leap team should reconsider because it is very helpful.

Thank you!

2 Likes

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.