Equipment Slot
Scripting with the EquipmentSlot class.
The EquipmentSlot
class serves as the slots used for equipping items by the Equipment.
Fields & Properties
positionIndex
The index of the position to use.
int
public
name
The name of the slot. Used for searching purposes.
string
public
itemStack
The equipped item.
ItemStack
public
backgroundIcon
The background icon of the slot.
Sprite
public
backgroundIconColorTint
The background icon color tint.
Color
public
itemType
The item type that is accepted by the slot.
ItemType
public
HasItem
If this slot has an item.
bool
public
Creating a Slot
While it's recommended to use the Equipment to create slots, it's possible to create them through code at runtime.
Setting Items
Equipment slots can equip an Item Stack. In the examples below, mySlot
is an instance of an EquipmentSlot
.
Checking If Equipping Is Possible
You can check if an item can be equipped by an equipment slot. Note that TryEquip already checks for this.
Equip An Item
The TryEquip
method attempts to equip an ItemStack
. This method returns true if the item stack was successfully equipped. This may fail if the slot restricts the type of the item.
Unequip An Item
Switching Items
The TrySwitch
method attempts to switch item stacks with another slot. This method returns true if the switch was successful. This may fail if the slot cannot equip the item of the other slot (restricted type).
Action Menu Options
By default, equipment slots' UI counterpart logically display item options for the Action Menu. You can override these options by editing the EquipmentSlot.actionMenuOptionsGetter
field.
Here's an example of how you can override these options:
You can call the GetActionMenuOptions
method to get the options.
Last updated