Forum Discussion
0ctipusPrime
2 years agoExplorer
Making buttons react to MouseClicks as well as Poke/Ray cast
Hello, I am trying to make buttons react to both poking and mouse clicks in Play Mode in Unity. I got poking working through prefabs, but am struggling to add the functionality where they are triggered by mouse clicks as well. Has anyone done this?
The reason is so that I speed up development on Mac since currently I have to build the program, put on headset, test it, attempt to fix issues, repeat. Each round taking way too long.
Thank you for your help.
3 Replies
Replies have been turned off for this discussion
- KoanDev2Honored Guest
Found the Solution? I have the exact same issue.
- 0ctipusPrimeExplorer
Hi, yes, I ended up adding the normal Unity Button functionality onto the meta prefab. I implemented it as custom script (below) on the Button Panel game object (under Button Visual). I have to put the reference to the actual function at two places but that is a small price to pay for the benefit.
using UnityEngine; using UnityEngine.Events; using UnityEngine.EventSystems; public class EventClick : MonoBehaviour, IPointerClickHandler { public GameObject parent; public UnityEvent onClick; public void OnPointerClick(PointerEventData eventData) { Debug.Log("Clicked: " + parent.name); if(onClick != null) onClick.Invoke(); } }
- Anton111111Expert Protege
If your mac on Apple Silicon you can use Meta XR simulator https://developers.meta.com/horizon/documentation/unity/xrsim-getting-started/
I had to move to windows pc from intel mac ;( Meta XR simulator speed up development very well.
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago