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 : ParagonUIBehaviour

Inheritance: SerializedMonoBehaviourParagonBehaviourParagonUIBehaviour → 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 selectedColor and selectedFontSize (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

Goal
How

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

Property
Type
Description

Channel

ChatChannel

The chat channel this tab represents

Fields

Field
Type
Access
Description

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.

circle-info

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.

Parameter
Type
Description

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

circle-exclamation
circle-exclamation

See Also

Last updated