ChatTabs

Tab bar component that creates, manages, and switches between ChatTab instances — one per chat channel. Provides sequential tab cycling for next/previous navigation.

Definition

Namespace: Paragon.Townskeep Assembly: Townskeep.dll

public class ChatTabs : ParagonUIBehaviour

Inheritance: SerializedMonoBehaviourParagonBehaviourParagonUIBehaviour → ChatTabs

Remarks

ChatTabs is the controller for the tab bar in the chat UI. On Initialize(), it creates one ChatTab per registered ChatChannel (queried via Chat.GetChannels()), then auto-selects the first tab.

Tab Creation

CreateTabs() follows a reuse-then-create pattern:

  1. Collects any pre-existing ChatTab children in the hierarchy

  2. Iterates over Chat.GetChannels() — reusing existing tabs by index, creating new ones from tabPrefab as needed

  3. Destroys any surplus tabs beyond the channel count

  4. Subscribes each tab's OnClicked to SelectTab()

Tab Selection

When a tab is selected (via click or programmatic call):

  1. The previous tab is visually deselected (Unselect())

  2. The new tab is visually selected (Select())

  3. The ChatWindow is switched to the new tab's channel via chatHUD.Window.SetChannel()

  4. The OnTabSelected event fires

Cycling

SwitchNextTab() and SwitchPreviousTab() wrap around — cycling past the last tab returns to the first, and vice versa.

Quick Lookup

Goal
How

Initialize

tabs.Initialize(chatHUD)

Select a specific tab

tabs.SelectTab(tab)

Next tab (wraps)

tabs.SwitchNextTab()

Previous tab (wraps)

tabs.SwitchPreviousTab()

Listen for tab changes

tabs.OnTabSelected += handler

Fields

Field
Type
Access
Description

tabPrefab

GameObject

[SerializeField]

Prefab instantiated when more tabs are needed than exist in the hierarchy

Events

OnTabSelected

Fired when a tab is selected (by click or programmatic call). Passes the newly selected ChatTab.

Methods

Initialize

Creates tabs for all registered channels and selects the first one.

Parameter
Type
Description

chatHUD

ChatHUD

Parent chat HUD, used to access Window for channel switching

SelectTab

Selects a tab: deselects the previous, applies visual selection, switches the window channel, and fires OnTabSelected.

Parameter
Type
Description

tab

ChatTab

The tab to select

SwitchNextTab

Selects the next tab in the list. Wraps to the first tab when at the end.

SwitchPreviousTab

Selects the previous tab in the list. Wraps to the last tab when at the beginning.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

Examples

Programmatic Tab Switching

See Also

Last updated