I’m having a hell of time getting a 2D polygon collider to register a mouse click. I’ve attached images and code to show where I’m at. I cannot get the click to work. What am I doing wrong here? Need help!
using UnityEngine;
using System.Collections;
public class MouseClick : MonoBehaviour
{
void OnMouseDown()
{
Debug.Log ("Clicked the Collider!");
}
}
You will also need to change the format of your handler function to match this interface.
public class MouseClick : MonoBehaviour, IPointerDownHandler
{
public void OnPointerDown(EventSystems.PointerEventData eventData);
{
Debug.Log ("pointer down while over the Collider!");
}
}