ChatTab - jimdroberts/FishMMO GitHub Wiki
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.
-
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.
-
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.
- Attach
ChatTab
to a chat tab UI GameObject in the Unity Editor. - Assign the
Label
field in the Inspector. - Integrate with the chat UI and channel picker for dynamic channel management.
// 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);
- 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.