コード例 #1
0
    public IEnumerator MoveToSlot(SlotGroup slotGroup, RectTransform slot, PointerEventData eventData)
    {
        // Vector2 newPos = slotGroup.GetNewPos(this);

        /*	if there's no dragged icon obj create it here
         */
        // Transform iconTrans = m_draggedIcon.transform;
        RectTransform iconRT = m_draggedIcon.GetComponent <RectTransform>();
        // Vector2 curPos = new Vector2(iconTrans.position.x, iconTrans.position.y);
        Vector2 curPos = iconRT.anchoredPosition;

        RectTransform canvasRect = m_canvas.GetComponent <RectTransform>();
        // Vector2 newSlotPosScreenSpace = RectTransformUtility.WorldToScreenPoint(null, slot.position);
        Vector3 newSlotPosOnCanvas = Vector3.zero;

        RectTransformUtility.ScreenPointToWorldPointInRectangle(canvasRect, /*newSlotPosScreenSpace*/ slot.position, eventData.pressEventCamera, out newSlotPosOnCanvas);

        Vector2 newPos = new Vector2(newSlotPosOnCanvas.x - canvasRect.rect.width * .5f, newSlotPosOnCanvas.y - canvasRect.rect.height * .5f);


        yield return(StartCoroutine(Move(iconRT, curPos, newPos, .5f)));

        DestroyDraggedIcon();
        // m_PickAmount = 0;
        m_pickAmount = 0;
        // Attach(slot);

        /*	call slotGroup.CompleteSlotsUpdate()
         *      Destroy Self
         */

        slotGroup.CompleteSlotsUpdate();
        m_slotGroupManager.SetActiveStateAll(true);
        if (this.m_OrigSG.m_slotGroupType != SlotGroupType.Pool)
        {
            Destroy(this.gameObject);
        }
        // DebugUtility.PrintBlue(this.m_itemInstance.name + "'s MoveToSlot's end is reached ");
    }