protected override void OnDragDropRelease(GameObject surface)
    {
        base.OnDragDropRelease(surface);

        if (dragItemController != null)
        {
            dragItemController.SetObjInWindows();
            dragItemController.chooseDragObject = null;
        }

        // Re-enable the drag scroll view script
        if (mDragScrollView != null)
        {
            StartCoroutine(EnableDragScrollView());
        }
    }
Пример #2
0
    /// <summary>
    /// Drop the item onto the specified object.
    /// </summary>

    protected virtual void OnDragDropRelease(GameObject surface)
    {
        if (!cloneOnDrag)
        {
            // Re-enable the collider
            if (mButton != null)
            {
                mButton.isEnabled = true;
            }
            else if (mCollider != null)
            {
                mCollider.enabled = true;
            }
            else if (mCollider2D != null)
            {
                mCollider2D.enabled = true;
            }

            // Is there a droppable container?
            UIDragDropContainer container = surface ? NGUITools.FindInParents <UIDragDropContainer>(surface) : null;

            if (container != null)
            {
                // Container found -- parent this object to the container
                mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

                Vector3 pos = mTrans.localPosition;
                pos.z = 0f;
                mTrans.localPosition = pos;
            }
            else
            {
                // No valid container under the mouse -- revert the item's parent
                mTrans.parent = mParent;
            }

            // Update the grid and table references
            mParent = mTrans.parent;
            mGrid   = NGUITools.FindInParents <UIGrid>(mParent);
            mTable  = NGUITools.FindInParents <UITable>(mParent);

            // Re-enable the drag scroll view script
            if (mDragScrollView != null)
            {
                StartCoroutine(EnableDragScrollView());
            }

            // Notify the widgets that the parent has changed
            NGUITools.MarkParentAsChanged(gameObject);

            if (mTable != null)
            {
                mTable.repositionNow = true;
            }
            if (mGrid != null)
            {
                mGrid.repositionNow = true;
            }
            // We're now done
            OnDragDropEnd();
        }
        else
        {
            NGUITools.Destroy(gameObject);
        }
        if (GameObject.Find("DragItemController"))
        {
            DragItemController item = GameObject.Find("DragItemController").GetComponent <DragItemController>();
            item.SetObjInWindows();
            item.chooseDragObject = null;
        }
    }