Пример #1
0
        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);
        }
Пример #2
0
        protected override void DrawPropertyLayout(GUIContent label)
        {
            base.DrawPropertyLayout(label);

            // Draws a drop-zone where we can destroy items.
            var rect = GUILayoutUtility.GetRect(0, 40).Padding(2);
            var id   = DragAndDropUtilities.GetDragAndDropId(rect);

            DragAndDropUtilities.DrawDropZone(rect, null as UnityEngine.Object, null, id);
            DragAndDropUtilities.DropZone <ItemSlot>(rect, new ItemSlot(), false, id);
        }