UIEquipmentButton - jimdroberts/FishMMO GitHub Wiki

Description

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.


API Access

Fields

  • public ItemSlot ItemSlotType

    The type of equipment slot this button represents (e.g., Head, Chest).

Methods

  • 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.


Basic Usage

Setup

  1. Attach UIEquipmentButton to an equipment slot button UI GameObject in the Unity Editor.
  2. Assign the ItemSlotType field in the Inspector to match the intended equipment slot.
  3. Integrate with the drag-and-drop, equipment, inventory, and bank systems for full functionality.

Example

// 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();

Best Practices

  • 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.
⚠️ **GitHub.com Fallback** ⚠️