コード例 #1
0
        void ReplaceDropTarget(DragDropTarget oldTarget, DragDropTarget newTarget)
        {
            if (oldTarget == newTarget)
            {
                return;
            }

            if (oldTarget)
            {
                oldTarget.OnItemExit(currentEventData);
                OnItemExit(currentEventData);
            }
            currentEventData.target = newTarget;
            if (newTarget)
            {
                newTarget.OnItemEnter(currentEventData);
                OnItemEnter(currentEventData);
            }
        }
コード例 #2
0
        public void OnPointerDown(PointerEventData eventData)
        {
            DragDropEventData.current.Reset();
            scrollRect = DragDropHelper.FindComponentUpward <ScrollRect>(transform);
            DragDropEventData.current.item             = this;
            DragDropEventData.current.eligibleForClick = true;

            if (attachedTarget)
            {
                lastTarget = attachedTarget;
            }
            else
            {
                Debug.LogError("will detach from a non-target parent");
            }

            if (delayDetach && !freeItem)
            {
                StartCoroutine(DelayHandleDragDropEvent());
            }
        }
コード例 #3
0
 public static bool TryRemoveItem(DragDropItem item, DragDropTarget target)
 {
     if (item.attachedTarget == target && target.HasItemAttached(item))
     {
         DragDropEventData eventData = new DragDropEventData();
         eventData.Reset();
         eventData.external = true;
         eventData.target   = target;
         eventData.item     = item;
         target.OnItemDetach(eventData);
         item.OnItemDetach(eventData);
         target.OnItemExit(eventData);
         item.OnItemExit(eventData);
         item.OnSetFree(eventData);
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #4
0
        public void OnPointerDown(PointerEventData eventData)
        {
            currentEventData.Reset();
            scrollRect                        = DragDropHelper.FindComponentUpward <ScrollRect>(transform);
            currentEventData.item             = this;
            currentEventData.eligibleForClick = true;

            if (attachedTarget)
            {
                lastTarget = attachedTarget;
                lastParent = attachedTarget.targetParent;
            }
            else
            {
                lastParent = transform.parent;
            }

            if (delayDetach && !freeItem)
            {
                StartCoroutine(DelayHandleDragDropEvent());
            }
        }
コード例 #5
0
        public static bool TryRemoveItem(DragDropItem item, DragDropTarget target, bool sendCallback = true)
        {
            if (item == null || target == null)
            {
                return(false);
            }

            if (item.attachedTarget == target && target.HasItemAttached(item))
            {
                DragDropEventData eventData = new DragDropEventData(!sendCallback);
                eventData.Reset();
                eventData.target = target;
                eventData.item   = item;
                target.OnItemDetach(eventData);
                item.OnItemDetach(eventData);
                item.OnSetFree(eventData);
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
        public void OnDrag(PointerEventData eventData)
        {
            if (!HandlingDragDropEvent())
            {
                return;
            }

            if (rectTransform)
            {
                Vector3 pointerPos;
                if (RectTransformUtility.ScreenPointToWorldPointInRectangle(rectTransform, eventData.position, eventData.pressEventCamera, out pointerPos))
                {
                    rectTransform.position = pointerPos;
                }
            }

            DragDropTarget newTarget = DragDropRegistry.Instance.FindDropTarget(eventData, this);

            if (newTarget != DragDropEventData.current.target)
            {
                ReplaceDropTarget(DragDropEventData.current.target, newTarget);
            }
        }
コード例 #7
0
 public LinkedListNode <DragDropTarget> Register(DragDropTarget target)
 {
     return(managedTargets.AddLast(target));
 }
コード例 #8
0
 public static bool IsChannelMatch(DragDropTarget target, DragDropItem item)
 {
     return((target.matchingChannel & item.matchingChannel) != 0);
 }
コード例 #9
0
 public static bool InitializePair(DragDropItem item, DragDropTarget target)
 {
     item.SetInitialTarget(target);
     return(true);
 }