Skip to content

Instantly share code, notes, and snippets.

@HectorPulido
Created April 28, 2018 01:37
Show Gist options
  • Save HectorPulido/b9ea1ea9e65f7c1740dd4c42f7802e6e to your computer and use it in GitHub Desktop.
Save HectorPulido/b9ea1ea9e65f7c1740dd4c42f7802e6e to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class buttontest : MonoBehaviour {
// Use this for initialization
void Start()
{
EventTrigger trigger = GetComponent<EventTrigger>();
EventTrigger.Entry PointerClick = new EventTrigger.Entry();
PointerClick.eventID = EventTriggerType.PointerDown;
PointerClick.callback.AddListener((data) => { count = 0; clicking = true; });
trigger.triggers.Add(PointerClick);
EventTrigger.Entry PointerUp = new EventTrigger.Entry();
PointerUp.eventID = EventTriggerType.PointerUp;
PointerUp.callback.AddListener((data) => {
print(count);
if (count > 3 && count <= 6)
{
print("EjecutarAccion1");
}
else if (count > 6)
{
print("Ejecutaraccion2");
}
clicking = false;
count = 0;
});
trigger.triggers.Add(PointerUp);
}
bool clicking;
float count;
private void Update()
{
if (clicking)
{
count += Time.deltaTime;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment