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 trigger...
KoanDev2
1 year agoHonored Guest
Found the Solution? I have the exact same issue.
0ctipusPrime
1 year agoExplorer
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();
}
}
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
- 6 months ago