public void OnBeginDrag(PointerEventData data) { if (allowOnlyLeftClickDragging && data.button != PointerEventData.InputButton.Left) { return; } IsBeingDragged = true; RemoveFromSlot(); // This hack prevents the grid layout from messing up with the position when the item is reparented. var gridLayout = RectT.parent.GetComponent <GridLayoutGroup>(); if (gridLayout != null) { gridLayout.enabled = false; } RectT.SetParent(GUIManager.DefaultCanvas.transform, worldPositionStays: true); if (gridLayout != null) { gridLayout.enabled = true; } RectT.SetToScreenPosition(GUIManager.DefaultCanvas, data.position); RectT.sizeDelta = originalSize * sizeMultiplier; }
protected void Reparent(Transform parent) { RectT.SetParent(parent, worldPositionStays: false); RectT.Center(); }