ChatTab - jimdroberts/FishMMO GitHub Wiki

Description

A UI component representing a chat tab in the FishMMO client. Manages the set of active chat channels for the tab, handles tab removal, and provides methods for toggling channel visibility and selection. Integrates with the chat UI and channel picker for dynamic chat management.


API Access

Fields

  • public Action OnRemoveTab

    Event triggered when this tab is removed.

  • public TMP_Text Label

    The label text component for the tab name.

  • public HashSet ActiveChannels

    The set of active chat channels for this tab. All channels are active by default.

Methods

  • public void RemoveTab()

    Removes this chat tab from the UI and triggers the OnRemoveTab event. Hides and destroys the tab GameObject.

  • public void ToggleUIChatChannelPicker()

    Toggles the visibility of the chat channel picker UI and activates it for this tab if visible.

  • public void ToggleActiveChannel(ChatChannel channel, bool value)

    Toggles the active state of a chat channel for this tab. Adds or removes the channel from the active set.


Basic Usage

Setup

  1. Attach ChatTab to a chat tab UI GameObject in the Unity Editor.
  2. Assign the Label field in the Inspector.
  3. Integrate with the chat UI and channel picker for dynamic channel management.

Example

// Example usage in a MonoBehaviour
public ChatTab chatTab;

void Start() {
    chatTab.Label.text = "General";
}

// To remove the tab
chatTab.RemoveTab();

// To toggle a channel
chatTab.ToggleActiveChannel(ChatChannel.World, false);

Best Practices

  • Always assign the Label in the Inspector to display the tab name.
  • Use the OnRemoveTab event to handle cleanup or UI updates when a tab is removed.
  • Keep the ActiveChannels set in sync with the user's channel preferences.
  • Integrate with the channel picker UI for a better user experience.
⚠️ **GitHub.com Fallback** ⚠️