修改拖拽失效问题
This commit is contained in:
parent
dcfd193bcb
commit
d5ca2d2d83
|
|
@ -13,12 +13,27 @@ public class DragWindow : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDr
|
|||
/// 是否忽略是否在UI上保持可拖动?
|
||||
/// </summary>
|
||||
[Header("是否忽略是否在UI上保持可拖动?")]
|
||||
public bool IgnoretheUI = false;
|
||||
public bool IgnoretheUI;
|
||||
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (transform.name.Equals("Panel任务小窗") || transform.name.Equals("PanelTaskPrompt"))
|
||||
{
|
||||
IgnoretheUI = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
IgnoretheUI = false;
|
||||
}
|
||||
}
|
||||
//刚开始拖拽时第一下触发这个函数
|
||||
public void OnBeginDrag(PointerEventData eventData)
|
||||
{
|
||||
|
||||
if (IgnoretheUI == false)
|
||||
{
|
||||
if (EventSystem.current.IsPointerOverGameObject()) return;
|
||||
}
|
||||
if (RectTransformUtility.RectangleContainsScreenPoint(transform as RectTransform, Input.mousePosition))
|
||||
{
|
||||
//1、计算所有需要的数据 image本身的坐标 鼠标所在的位置相对于Canvas的本地坐标
|
||||
|
|
@ -39,7 +54,11 @@ public class DragWindow : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDr
|
|||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
|
||||
if (EventSystem.current.IsPointerOverGameObject()) return;
|
||||
|
||||
if (IgnoretheUI == false)
|
||||
{
|
||||
if (EventSystem.current.IsPointerOverGameObject()) return;
|
||||
}
|
||||
if (CanDrag)
|
||||
{
|
||||
Vector2 localPosition;
|
||||
|
|
@ -53,8 +72,12 @@ public class DragWindow : MonoBehaviour, IDragHandler, IBeginDragHandler, IEndDr
|
|||
//停止拖拽
|
||||
public void OnEndDrag(PointerEventData eventData)
|
||||
{
|
||||
|
||||
if (EventSystem.current.IsPointerOverGameObject()) return;
|
||||
|
||||
|
||||
if (IgnoretheUI == false)
|
||||
{
|
||||
if (EventSystem.current.IsPointerOverGameObject()) return;
|
||||
}
|
||||
CanDrag = false;
|
||||
if (isFirstDrag && transform.Find("tip"))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue