Exemple #1
0
    //拖拽释放,没有落在停靠表面的处理
    void DragDropReleaseLostSurface()
    {
        QKDragDropSurface cm_ownersurface = null;

        {
            if (OwnerSurface != null)
            {
                cm_ownersurface = OwnerSurface.GetComponent <QKDragDropSurface>();
            }
        }

        NotifyDragDropCancelling(OwnerSurface, this);

        if (cm_ownersurface != null && cm_ownersurface.FlyOnCancel && UIFlyRoot.Single != null)//飞回
        {
            UIFly cmFly = UIFly.Go(gameObject, m_StartPos, cm_ownersurface.FlyStrength);
            //cmFly.flyFinishedAction = UIFly.FlyFinishedAction.DestroyGameobject;
            cmFly.StartFly(OnFlyEnd);
        }
        else//直接销毁
        {
            if (!m_bkCloneOnDrag)//拖拽的时候没有进行克隆
            {
                NotifyDragDropLeaveItem(m_bkDropSurface, this);//通知旧容器 对象离开
            }
            //通知容器 拖拽取消
            NotifyDragDropCancel(OwnerSurface, this);

            //销毁物体
            NGUITools.Destroy(gameObject);
        }
    }
Exemple #2
0
    static void NotifyDragDropLeaveItem(QKDragDropSurface dropSurface, QKDragDropItem dragDropItem)
    {
        if (dropSurface == null)
        {
            return;
        }

        dropSurface.OnDragDropLeaveItem(dragDropItem);
    }
Exemple #3
0
    static void NotifyDragDropJoinItem(GameObject OwnerSurface, QKDragDropItem dragDropItem)
    {
        QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>();

        if (dropSurface == null)
        {
            return;
        }

        dropSurface.OnDragDropJoinItem(dragDropItem);
    }
Exemple #4
0
    //通知容器 拖拽开始
    static void NotifyDragDropStart(GameObject OwnerSurface, QKDragDropItem dragDropItem)
    {
        ShowBaffle(true);

        QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>();

        if (dropSurface == null)
        {
            return;
        }
        dropSurface.OnDragDropStart(dragDropItem);
    }
Exemple #5
0
    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);
        }
    }
Exemple #6
0
    static void   NotifyDragDropEnd(GameObject OwnerSurface, QKDragDropItem dragDropItem)
    {
        IsDraging = false;

        ShowBaffle(false);

        QKDragDropSurface dropSurface = OwnerSurface.GetComponent <QKDragDropSurface>();

        if (dropSurface == null)
        {
            return;
        }

        dropSurface.OnDragDropEnd(dragDropItem);
    }
Exemple #7
0
    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);//销毁实例
        }
    }
Exemple #8
0
    /// <summary>
    /// 拖拽释放鼠标
    /// </summary>
    protected override void OnDragDropRelease(GameObject surface)
    {
        surface = QKDragDropItem.hoveredObject;

        //降低widget深度
        NGuiHelper.DepthUpward(gameObject, -50);


        if (surface == null)
        {
            DragDropReleaseLostSurface();
            return;
        }

        QKDragDropSurface dropSurface = NGUITools.FindInParents <QKDragDropSurface>(surface);

        if (
            dropSurface == null ||                              //没有落在停靠表面上
            (dropSurface == m_bkDropSurface && m_bkCloneOnDrag) //停靠表面和拖动前是同一个 且 采用克隆方式拖出
            )
        {
            DragDropReleaseLostSurface();
            return;
        }



        if (dropSurface.Dock(gameObject))//停靠成功了
        {
            //通知原容器 拖拽完成
            NotifyDragDropEnd(OwnerSurface, this);

            //变更所属容器
            OwnerSurface = dropSurface.gameObject;

            //自动处理UIScrollView
            var dragScrollView = gameObject.GetComponent <UIDragScrollView>();
            if (dragScrollView != null)//绑定了滚动视图拖动组件
            {
                //设置新的滚动视图
                dragScrollView.scrollView = NGUITools.FindInParents <UIScrollView>(gameObject.transform.parent);
            }

            bool isGird = NGUITools.FindInParents <UIGrid>(gameObject.transform.parent);

            //如没拖出当前平面则不需要发起通知并且重新排序
            if (isGird || (!m_bkCloneOnDrag && dropSurface != m_bkDropSurface)) //拖拽的时候没有进行克隆
            {
                NotifyDragDropLeaveItem(m_bkDropSurface, this);                 //通知旧容器 对象离开
            }
            if (isGird || dropSurface != m_bkDropSurface)
            {
                //通知新容器 有新的对象进入
                NotifyDragDropJoinItem(OwnerSurface, this);
            }
        }
        else
        {
            DragDropReleaseLostSurface();
        }
    }