UIEquipmentButton - jimdroberts/FishMMO GitHub Wiki
A UI button representing an equipment slot in the FishMMO client. Handles drag-and-drop, equipping from inventory or bank, and unequipping to inventory. Integrates with the equipment, inventory, and bank controllers, and broadcasts equip/unequip events to the server.
-
public ItemSlot ItemSlotType
The type of equipment slot this button represents (e.g., Head, Chest).
-
public override void OnLeftClick()
Handles left mouse click events for equipment buttons. Supports equipping items from inventory or bank, and drag-and-drop logic.
-
public override void OnRightClick()
Handles right mouse click events for equipment buttons. Unequips the item and sends it to the inventory.
-
public override void Clear()
Clears the UI elements for this equipment button.
- Attach
UIEquipmentButton
to an equipment slot button UI GameObject in the Unity Editor. - Assign the
ItemSlotType
field in the Inspector to match the intended equipment slot. - Integrate with the drag-and-drop, equipment, inventory, and bank systems for full functionality.
// Example usage in a MonoBehaviour
public UIEquipmentButton equipmentButton;
equipmentButton.ItemSlotType = ItemSlot.Head;
void Start() {
// Set up the button as needed
}
// On left click
equipmentButton.OnLeftClick();
// On right click
equipmentButton.OnRightClick();
- Always assign the
ItemSlotType
in the Inspector to avoid logic errors. - Integrate with the drag-and-drop system for interactive UI.
- Use the
Clear()
method to reset the button state when needed. - Validate slot indices and inventory types before broadcasting events.