Skip to content

Instantly share code, notes, and snippets.

@arket
Last active August 29, 2015 14:20
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 arket/9017bc8ae052f7b1cbe1 to your computer and use it in GitHub Desktop.
Save arket/9017bc8ae052f7b1cbe1 to your computer and use it in GitHub Desktop.
即席UnityEvent Clickカスタム
using UnityEngine;
using System.Collections;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class CustomEventClick : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {
public UnityEvent customClick;
Vector2 beginPosition; // クリック開始位置
// 初め
public void OnPointerDown(PointerEventData data) {
Clear();
beginPosition = data.position;
}
// 離された
public void OnPointerUp(PointerEventData data) {
// クリック判定
if(data.position == beginPosition) {
customClick.Invoke();
}
Clear();
}
void Clear () {
beginPosition = Vector2.zero;
}
}
@arket
Copy link
Author

arket commented Apr 27, 2015

Event TriggerのDragとClickのイベントを分ける用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment