public void OnBeginDrag(PointerEventData eventData) { Debug.Log("OnBeginDrag"); // play grab sound //SoundManager.instance.PlaySingle(SoundManager.dicePickUp); // itemToDrag is the game object that this script is on itemToDrag = gameObject; startPos = transform.position; startParent = transform.parent; if (startParent.gameObject.name == "ItemSlot") { itemBox.ItemFromNetwork(true); } else { itemBox.ItemFromNetwork(false); } // set the anchors of the dice so it'll follow mouse correctly gameObject.GetComponent <RectTransform>().anchorMin = new Vector2(0.5f, 0.5f); gameObject.GetComponent <RectTransform>().anchorMax = new Vector2(0.5f, 0.5f); // set the parent to canvas so the dice slot will no longer have a child transform.SetParent(GameObject.Find("ItemBox").transform); // allows to pass events through the item being dragged GetComponent <CanvasGroup>().blocksRaycasts = false; }