# Clicking on button using Controller

**URL:** <https://forum.magicleap.cloud/t/clicking-on-button-using-controller/3812>\
**Category:** Unity Development\
**Tags:** controller, input\
**Created:** [July 20, 2024, 2:00pm UTC](https://forum.magicleap.cloud/t/clicking-on-button-using-controller/3812 "2024-07-20T14:00:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shubhgajjar2004](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@shubhgajjar2004](https://forum.magicleap.cloud/u/shubhgajjar2004)\
**Post date:** [July 20, 2024, 2:00pm UTC](https://forum.magicleap.cloud/t/clicking-on-button-using-controller/3812/1 "2024-07-20T14:00:05Z")

</div>

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:  
 ![image](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/5/5da59b4c0ca4390e45588cb0b7672b510196dad3.png)
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](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/2X/c/c1c3d5811319fdbd045e0bab6246985652398d69.png)

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.

---

<div class="post-metadata">

**Author:** ![shubhgajjar2004](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@shubhgajjar2004](https://forum.magicleap.cloud/u/shubhgajjar2004)\
**Post date:** [July 21, 2024, 5:09am UTC](https://forum.magicleap.cloud/t/clicking-on-button-using-controller/3812/2 "2024-07-21T05:09:04Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/magicleap1/original/1X/bd9b737a4d45ea243aa7eb177d60a773b806899a.svg) [@system](https://forum.magicleap.cloud/u/system)\
**Post date:** [August 5, 2024, 5:09am UTC](https://forum.magicleap.cloud/t/clicking-on-button-using-controller/3812/3 "2024-08-05T05:09:16Z")

</div>

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