protected override ItemSlot DrawElement(Rect rect, ItemSlot value) { var id = DragAndDropUtilities.GetDragAndDropId(rect); DragAndDropUtilities.DrawDropZone(rect, value.item ? value.item.icon : null, null, id); // Draws the drop-zone using the items icon. if (value.item != null) { if (value.item.stackSize > 1) { // Item count var countRect = rect.Padding(2).AlignBottom(16); value.itemCount = EditorGUI.IntField(countRect, Mathf.Max(1, value.itemCount)); if (value.itemCount > value.item.stackSize) { value.itemCount = value.item.stackSize; } GUI.Label(countRect, "/ " + value.item.stackSize, SirenixGUIStyles.RightAlignedGreyMiniLabel); } } value = DragAndDropUtilities.DropZone(rect, value); // Drop zone for ItemSlot structs. value.item = DragAndDropUtilities.DropZone <Item>(rect, value.item); // Drop zone for Item types. value = DragAndDropUtilities.DragZone(rect, value, true, true); // Enables dragging of the ItemSlot return(value); }
private void AddDragHandles(OdinMenuItem menuItem) { menuItem.OnDrawItem += x => DragAndDropUtilities.DragZone(menuItem.Rect, menuItem.Value, false, false); }