Unity UGUI点击、拖动等事件
来源:互联网 发布:最短路径算法floyd实例 编辑:程序博客网 时间:2024/05/21 09:39
using UnityEngine;using UnityEngine.Events;using UnityEngine.EventSystems;// 别忘记引入using System.Collections;public class UIOnClickTest : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler, IPointerClickHandler{ public float interval = 0.1f; [SerializeField] UnityEvent m_OnLongpress = new UnityEvent(); private bool isPointDown = false; private float lastInvokeTime; // Update is called once per frame void Update() { if (isPointDown) { if (Time.time - lastInvokeTime > interval) { //触发点击; m_OnLongpress.Invoke(); lastInvokeTime = Time.time; Debug.Log("长按"); } } } public void OnPointerDown(PointerEventData eventData) { m_OnLongpress.Invoke(); isPointDown = true; lastInvokeTime = Time.time; Debug.Log("鼠标按下"); } public void OnPointerUp(PointerEventData eventData) { isPointDown = false; Debug.Log("鼠标抬起"); } public void OnPointerExit(PointerEventData eventData) { isPointDown = false; Debug.Log("鼠标退出"); } public void OnPointerClick(PointerEventData eventData) { isPointDown = false; Debug.Log("鼠标点击"); }}
阅读全文
0 0
- Unity UGUI点击、拖动等事件
- Unity 4.6 uGUI的点击事件
- Unity UGUI不规则图片点击事件处理
- Unity UGUI按钮动态添加点击事件
- unity ugui对场景中鼠标点击事件的遮挡
- unity UGUI 事件接口
- Unity UGUI事件系统
- UGUI点击响应事件
- UGUI点击事件
- MUI各种手势事件:滑动、拖动、点击等
- Unity UGUI:Button点击响应
- Unity-UGUI的点击接口
- unity UGUI Button 点击之后按空格还是会触发点击事件
- unity UGUI Toggle事件管理
- Unity uGUI 长按事件
- UGUI点击事件(多个)
- UGUI点击事件(委托)
- 封装UGUI的点击事件
- matlab2c使用c++实现matlab函数系列教程-tan函数
- matlab2c使用c++实现matlab函数系列教程-cosh函数
- matlab2c使用c++实现matlab函数系列教程-sinh函数
- matlab2c使用c++实现matlab函数系列教程-asin函数
- matlab2c使用c++实现matlab函数系列教程-sin函数
- Unity UGUI点击、拖动等事件
- matlab2c使用c++实现matlab函数系列教程-cos函数
- 《DevOps 实践》
- Codeforces 851B
- 莫队 + 组合 + 逆元 HDU 5145
- CAGradientlayer设置视图背景的渐变效果
- 基于ArcGIS的Python编程秘笈笔记(一):面向ArcGIS的Python语言基础
- Logstash安装配置
- Map集合的四种种遍历方式