Skip to main content
New Participant
January 3, 2024

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. 

    This topic has been closed for replies.

    3 replies

    New Participant
    September 11, 2024

    Found the Solution? I have the exact same issue. 

    New Participant
    September 13, 2024

    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();
    }
    }

     

    Anton111111
    Inspiring
    September 21, 2024

    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.