36 lines
659 B
C#
36 lines
659 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class SimpleTouchAreaButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
|
{
|
|
private bool touched, canFire;
|
|
private int pointerID;
|
|
void Awake()
|
|
{
|
|
touched = false;
|
|
}
|
|
public void OnPointerDown(PointerEventData data)
|
|
{
|
|
if (!touched)
|
|
{
|
|
touched = true;
|
|
pointerID = data.pointerId;
|
|
canFire = true;
|
|
}
|
|
}
|
|
public void OnPointerUp(PointerEventData data)
|
|
{
|
|
if (data.pointerId == pointerID)
|
|
{
|
|
touched = false;
|
|
canFire = false;
|
|
}
|
|
}
|
|
public bool CanFire()
|
|
{
|
|
return canFire;
|
|
}
|
|
} |