Ejemplo n.º 1
0
 protected override void OnDragDropRelease(GameObject surface)
 {
     if (surface != null)
     {
         var e = new FarmMenuDragEvent(-1);
         EventDispatcher.Instance.DispatchEvent(e);
         NGUITools.Destroy(gameObject);
     }
 }
Ejemplo n.º 2
0
        protected override void StartDragging()
        {
            if (!interactable)
            {
                return;
            }

            if (!mDragging)
            {
                if (cloneOnDrag)
                {
                    mPressed = false;
                    var clone      = NGUITools.AddChild(memTransform.parent.gameObject, gameObject);
                    var cloneTrans = clone.transform;
                    cloneTrans.localPosition = memTransform.localPosition;
                    cloneTrans.localRotation = memTransform.localRotation;
                    cloneTrans.localScale    = memTransform.localScale;

                    var 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;
                    }

                    var item = clone.GetComponent <GroundMenuDragDropItem>();

                    item.CountLabel = item.GetComponentInChildren <UILabel>();
                    item.ItemLogic  = ItemLogic;
                    item.mTouch     = mTouch;
                    item.mPressed   = true;
                    item.mDragging  = true;
                    item.Start();
                    item.OnDragDropStart();

                    var boxCollider = clone.GetComponent <UIDragScrollViewSimple>();
                    if (boxCollider != null)
                    {
                        boxCollider.enabled = false;
                    }

                    if (UICamera.currentTouch == null)
                    {
                        UICamera.currentTouch = mTouch;
                    }

                    mTouch = null;

                    UICamera.Notify(gameObject, "OnPress", false);
                    UICamera.Notify(gameObject, "OnHover", false);

                    var e = new FarmMenuDragEvent(ItemLogic.Index);
                    EventDispatcher.Instance.DispatchEvent(e);
                }
                else
                {
                    mDragging = true;
                    OnDragDropStart();
                }
            }
        }