public void OnIconDrag(PointerEventData eventData, GameObject page) { // Log (TAG, "OnIconDrag eventData.position:"+eventData.position); // Log (TAG, "OnIconDrag current pageIndex:"+pageController.getCurrentPosition()+" drag page:"+page.GetComponent<PageLayout>().pageNumber); IconController action = currentDragIcon.GetComponent <IconController> (); action.OnDrag(eventData); RectTransform rt = currentDragIcon.GetComponent <RectTransform> (); Vector2 anchoredPosition = rt.anchoredPosition; Vector2 center = rt.rect.center; Vector2 iconCenter = new Vector2(anchoredPosition.x + center.x, anchoredPosition.y + center.y); // Log (TAG, "OnIconDrag iconCenter:"+iconCenter); int touchIndex = pageController.PointToIndex(iconCenter); // Log (TAG, "OnIconDrag touchIndex:"+touchIndex); // Log(TAG, "OnIconDrag dragIndex:"+iconMovingInfo.dragIndex+" dropIndex:"+iconMovingInfo.dropIndex); if (touchIndex == -1) { Log(TAG, "touchIndex == -1"); return; } if (iconMovingInfo.dropIndex != touchIndex) { CancelInvoke(); } if (iconMovingInfo.dragIndex != touchIndex) { iconMovingInfo.dropIndex = touchIndex; } if (iconMovingInfo.dropIndex == -1) { return; } if (iconMovingInfo.dragIndex == iconMovingInfo.dropIndex) { return; } Invoke("InvokeExchange", 0.4f); }