Esempio n. 1
0
        public void OnDrag(PointerEventData eventData)
        {
            // move the dragged object with the mouse
            if (dragging)
            {
                transform.position = eventData.position;
            }

            // highlight squares that can receive this component?
            Slot slot = GetSlotUnderMouse();

            if (slot != currentSlotOver)
            {
                if (slot)
                {
                    slot.OnDraggableEnter();
                }
                if (currentSlotOver)
                {
                    currentSlotOver.OnDraggableExit();
                }
                ObjectContainer oldContainer = currentSlotOver != null ? currentSlotOver.container : null;
                ObjectContainer newContainer = slot != null ? slot.container : null;
                if (oldContainer != null)
                {
                    oldContainer.OnDraggableExit();
                }
                if (newContainer != null)
                {
                    newContainer.OnDraggableEnter();
                }

                currentSlotOver = slot;
            }
        }