ChatTab
Individual tab button representing a single chat channel. Manages visual selection state (color and font size) and fires a click event consumed by ChatTabs to drive channel switching.
Definition
Namespace: Paragon.Townskeep
Assembly: Townskeep.dll
public class ChatTab : ParagonUIBehaviourInheritance: SerializedMonoBehaviour → ParagonBehaviour → ParagonUIBehaviour → ChatTab
Remarks
Each ChatTab corresponds to one ChatChannel. The tab is initialized with a channel reference, which sets the button label text and binds the click handler. When clicked, the tab fires OnClicked — which ChatTabs listens to in order to trigger SelectTab().
Visual State
The tab has two visual states controlled by text color and font size:
Selected — Uses
selectedColorandselectedFontSize(configured via[SerializeField])Unselected — Reverts to the default color and font size captured in
Awake()
State changes are applied by ChatTabs.SelectTab(), which calls Unselect() on the previous tab and Select() on the new one.
Cleanup
On OnDestroy(), the tab nulls out the OnClicked delegate and removes its button listener to prevent stale references.
Quick Lookup
Initialize with a channel
tab.Initialize(channel)
Select visually
tab.Select()
Deselect visually
tab.Unselect()
Listen for clicks
tab.OnClicked += handler
Get the channel
tab.Channel
Properties
Channel
ChatChannel
The chat channel this tab represents
Fields
selectedColor
Color
[SerializeField]
Text color when selected
selectedFontSize
float
[SerializeField]
Font size when selected
Events
OnClicked
Fired when the tab's button is clicked. Passes the clicked ChatTab instance.
This is a public Action<ChatTab> field, not a C# event. It can be reassigned (not just subscribed to) from external code. ChatTabs subscribes via += during CreateTabs().
Methods
Initialize
Binds the tab to a chat channel, sets the label text, and registers the button click listener.
channel
ChatChannel
The chat channel to bind to
Select
Applies the selected visual state (color and font size).
Unselect
Reverts to the default visual state (color and font size captured in Awake()).
Common Pitfalls
Default color/size captured in Awake()
The defaultColor and defaultFontSize are read from the TextMeshProUGUI component in Awake(). If the text component's initial values differ from the intended "unselected" state (e.g., due to prefab overrides), the unselected appearance will be wrong.
OnClicked is a field, not an event
Because OnClicked is a public Action<ChatTab> field (not event), it can be overwritten with = instead of +=. Be careful not to replace existing subscribers.
See Also
ChatTabs — container that creates and manages tabs
ChatWindow — displays messages for the selected channel
ChatHUD — root chat coordinator
Chat Overview — system architecture
Last updated