So I’m trying to make a clickergame. i want a menu to open when my sprite is clicked.
Righ now I’ve got a script that detects the click but it doesnt matter where I click, it just opens it.
using UnityEngine.EventSystems;
public class BuyMenuBB2 : MonoBehaviour, IPointerClickHandler
{
public GameObject buyMenu;
public void OnPointerClick(PointerEventData eventData)
{
throw new System.NotImplementedException();
}
private void Update()
{
if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject())
{
OpenBuyMenu();
}
}
public void OpenBuyMenu()
{
buyMenu.SetActive(true);
}
public void CloseBuyMenu()
{
buyMenu.SetActive(false);
}
}
I have a button setup that closes the menu.