detect click on ui element unity code example
Example 1: unity Check if mouse clicked UI element
EventSystem.current.IsPointerOverGameObject()
Example 2: detect object click unity
void Update () { } void OnMouseDown(){ // this object was clicked - do something Destroy (this.gameObject); }