public void OnDragDropCancelling(QKDragDropItem dragDropItem) { if (evt_DragDropCancelling != null) { evt_DragDropCancelling.Call(dragDropItem); } }
//拖拽开始 public void OnDragDropStart(QKDragDropItem dragDropItem) { if (evt_DragDropStart != null) { evt_DragDropStart.Call(dragDropItem); } }
//拖拽取消 public void OnDragDropCancel(QKDragDropItem dragDropItem) { if (evt_DragDropCancel != null) { evt_DragDropCancel.Call(dragDropItem); } }
//拖拽完成 public void OnDragDropEnd(QKDragDropItem dragDropItem) { if (evt_DragDropEnd != null) { evt_DragDropEnd.Call(dragDropItem); } }
//有对象离开 public void OnDragDropLeaveItem(QKDragDropItem dragDropItem) { if (evt_DragDropLeaveItem != null) { evt_DragDropLeaveItem.Call(dragDropItem); } }
static void NotifyDragDropLeaveItem(QKDragDropSurface dropSurface, QKDragDropItem dragDropItem) { if (dropSurface == null) { return; } dropSurface.OnDragDropLeaveItem(dragDropItem); }
static void NotifyDragDropJoinItem(GameObject OwnerSurface, QKDragDropItem dragDropItem) { QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>(); if (dropSurface == null) { return; } dropSurface.OnDragDropJoinItem(dragDropItem); }
//通知容器 拖拽开始 static void NotifyDragDropStart(GameObject OwnerSurface, QKDragDropItem dragDropItem) { ShowBaffle(true); QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>(); if (dropSurface == null) { return; } dropSurface.OnDragDropStart(dragDropItem); }
static void NotifyDragDropMoveing(GameObject OwnerSurface, QKDragDropItem dragDropItem) { //using (new MonoEX.SafeCall(() => { ShowBaffle(false); }, () => { ShowBaffle(true); })) { QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>(); if (dropSurface == null) { return; } dropSurface.OnDragDropMoveing(dragDropItem); } }
static void NotifyDragDropEnd(GameObject OwnerSurface, QKDragDropItem dragDropItem) { IsDraging = false; ShowBaffle(false); QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>(); if (dropSurface == null) { return; } dropSurface.OnDragDropEnd(dragDropItem); }
void OnFlyEnd() { QKDragDropItem dragDropItem = this; if (!m_bkCloneOnDrag)//拖拽的时候没有进行克隆 { //物品放回原位置 QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>(); if (dropSurface != null) { dropSurface.Dock(gameObject); } } NotifyDragDropCancel(dragDropItem.OwnerSurface, dragDropItem); if (m_bkCloneOnDrag) { GameObject.Destroy(gameObject);//销毁实例 } }
public bool CanDock(GameObject obj) { if (WidgetContainer == null) { return(false); } QKDragDropItem dropItem = obj.GetComponent <QKDragDropItem>(); if (dropItem == null) { return(false); } if (ItemTags == null || dropItem.tags == null) { return(false); } bool isok = false; foreach (string tag1 in ItemTags) { foreach (string tag2 in dropItem.tags) { if (tag1 == tag2) { isok = true; break; } } } if (isok == false) { return(false); } if (m_delegate_DockCheck != null) { //调用脚本的检查函数 object re = m_delegate_DockCheck.Call(dropItem); if (re == null) { return(false); } //释放返回值 IDisposable disp = re as IDisposable; if (disp != null) { disp.Dispose(); } if (Type.GetTypeCode(re.GetType()) == TypeCode.Boolean) { if ((bool)re == false) { return(false); } } } return(true); }
public override void StartDragging() { if (!interactable || IsDraging//当前有其它拖拽发生 ) { return; } if (!mDragging) { IsDraging = true;//同时只允许启动唯一一个拖拽 if (cloneOnDrag) { mPressed = false; GameObject clone = NGUITools.AddChild(transform.parent.gameObject, gameObject); clone.transform.localPosition = transform.localPosition; clone.transform.localRotation = transform.localRotation; clone.transform.localScale = transform.localScale; UIButtonColor bc = clone.GetComponent <UIButtonColor>(); if (bc != null) { bc.defaultColor = GetComponent <UIButtonColor>().defaultColor; } if (mTouch != null && mTouch.pressed == gameObject) { mTouch.current = clone; mTouch.pressed = clone; mTouch.dragged = clone; mTouch.last = clone; } QKDragDropItem item = clone.GetComponent <QKDragDropItem>();//wenchuan item.mTouch = mTouch; item.mPressed = true; item.mDragging = true; //wenchuan begin //QKDragDropItem oldItem = gameObject.GetComponent<QKDragDropItem>(); //处理用户参数 //if (oldItem.CloneUserDataDelegateFunc != null) // item.UserData = oldItem.CloneUserDataDelegateFunc(oldItem.UserData); //else item.UserData = //oldItem. UserData; //wenchuan end item.m_bkCloneOnDrag = cloneOnDrag; item.m_bkDropSurface = OwnerSurface.GetComponent <QKDragDropSurface>(); item.Start(); item.OnDragDropStart(); if (UICamera.currentTouch == null) { UICamera.currentTouch = mTouch; } mTouch = null; UICamera.Notify(gameObject, "OnPress", false); UICamera.Notify(gameObject, "OnHover", false); } else { m_bkCloneOnDrag = cloneOnDrag;//记录 m_bkDropSurface = OwnerSurface.GetComponent <QKDragDropSurface>(); mDragging = true; OnDragDropStart(); } } }