Files
Liubing\LB 3d8d4d18f3 first commit
先修复一下,错误的场景

删除不必要的钓场资产

修复into场景

update:更新meta文件,修复报错

update:修复资源

修复第一章节建造

修复建造第三章

update:删除多余内容

update:更新README.md

update:还原图标

update:更新README

update:更新配置
2026-04-28 02:17:22 +08:00

80 lines
1.9 KiB
C#

using UnityEngine;
using UnityEngine.EventSystems;
public class UIDrag : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IPointerDownHandler, IPointerUpHandler
{
//按下回调
public System.Action OnPointerDownCall;
public System.Action OnPointerUpCall;
//开始拖动回调
public System.Action OnBeginDragCall;
//拖动中回调
public System.Action<PointerEventData> OnDragCall;
//拖动结束回调
public System.Action OnEndDragCall;
bool isdrag = false;
public bool isTouchTwo = false;
public void OnPointerDown(PointerEventData eventData)
{
OnPointerDownCall?.Invoke();
}
public void OnPointerUp(PointerEventData eventData)
{
OnPointerUpCall?.Invoke();
}
public void OnBeginDrag(PointerEventData eventData)
{
#if UNITY_EDITOR
if (Input.GetMouseButton(0))
#else
if (Input.touchCount == 1 || Input.touchCount == 2)
#endif
{
OnBeginDragCall?.Invoke();
isdrag = true;
}
}
public void OnDrag(PointerEventData eventData)
{
OnDragCall?.Invoke(eventData);
if (isTouchTwo)
{
#if !UNITY_EDITOR
//if (Input.touchCount == 1)
//{
// if (!isdrag)
// {
// OnBeginDragCall?.Invoke();
// isdrag = true;
// }
//}
//else
if (Input.touchCount == 2)
{
//双指操作
if (isdrag)
{
OnEndDragCall?.Invoke();
isdrag = false;
}
}
#endif
}
}
public void OnEndDrag(PointerEventData eventData)
{
if (isdrag)
{
OnEndDragCall?.Invoke();
isdrag = false;
}
}
//双指操作
}