Skip to content

Instantly share code, notes, and snippets.

@walterpalladino
Created July 10, 2018 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterpalladino/83949f91d4effaeda7832ccc90687e8e to your computer and use it in GitHub Desktop.
Save walterpalladino/83949f91d4effaeda7832ccc90687e8e to your computer and use it in GitHub Desktop.
Detect Taps on UI Elements
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems; // Required when using Event data.
public class ClickableUIObject : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {
public bool clicked = false;
public void OnPointerDown (PointerEventData eventData)
{
Debug.Log("OnMouseDown");
clicked = true;
}
public void OnPointerUp(PointerEventData eventData)
{
Debug.Log("OnPointerUp");
clicked = false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment