Skip to main content

Button

A class in Root.Township, Alta.Meta.UI.

A simple button component for the in-game (meta) UI. Holds a label, enabled flag and pressed state, raises events, and plays press and release sounds if set.

Constructors​

MemberWhat it is
Button()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

MemberWhat it is
protected static Logger loggerNLog logger shared by all buttons.
6 private and internal fields
MemberWhat it is
private bool btnPressedInspector button that calls OnPressed.
private bool btnReleasedInspector button that calls OnReleased.
private bool isEnabledBacking field for IsEnabled.
private string labelBacking field for Label.
private ButtonSettings settingsBacking field for Settings.
private ButtonSoundSettings soundsSounds played on press and release.

Properties​

MemberWhat it is
bool IsEnabled { get; set; }Whether the button is enabled. Setting it raises EnabledChanged; nothing here stops Press when disabled.
string Label { get; set; }The button text. Setting it raises LabelChanged.
ButtonSettings Settings { get; set; }The ButtonSettings asset for the button. Setting it raises SettingsChanged.
bool State { get; private set; }True between Press and Release.

Events​

MemberWhat it is
event Action<Button> EnabledChangedRaised when IsEnabled changes.
event Action<Button> LabelChangedRaised when Label changes.
event Action<Button> PressedRaised by Press.
event Action<Button> ReleasedRaised by Release.
event Action<Button> SettingsChangedRaised when Settings changes.

Methods​

MemberWhat it is
void OnPressed()Same as Press; exists so the inspector debug button can call it.
void OnReleased()Same as Release; exists so the inspector debug button can call it.
void Press()Logs the press, sets State to true and raises Pressed.
void Release()Logs the release, sets State to false and raises Released.
1 private and internal method
MemberWhat it is
private void Awake()Hooks the press and release sounds from sounds, if set.

Used in​

Members of other types that take, return or hold a Button:

AssistedSpawnCommandAction.ConnectKeyboard, AssistedSpawnCommandAction.SubmitCommand, ButtonCollection.buttons, ButtonCollection.CurrentButton, ButtonCollection.HandleButtonPress, ButtonEvents.button, ButtonEvents.HandleEnabledChanged, ButtonWithEvents.HandleEnabledChanged, ConfirmPopupPanel.cancelButton, ConfirmPopupPanel.confirmButton, ConfirmPopupPanel.HandleCancelPressed, ConfirmPopupPanel.HandleConfirmPressed, ListElementWithButton.OnPressed, NavigateTo.button, OptionsPanel.GetPrefab, OptionsPanelButtonConfig.buttonPrefab, OptionsPanelButtonConfig.ButtonPrefab, GroupInfoTab.HandleLeaveButtonPress, InboxPanel.acceptButton, InboxPanel.declineButton, InboxPanel.HandleAccept, InboxPanel.HandleDecline, ReportsPanel.acceptButton, ReportsPanel.declineButton, ReportsPanel.HandleAccept, ReportsPanel.HandleDecline, ServerDetailsPanel.confirmButton, ServerDetailsPanel.ConfirmButtonPressed, TabletToggle.button, TextButton.OnLabelChanged, TouchScreenButtonVisual.button, TouchScreenButtonVisual.LabelChanged, TouchScreenButtonVisual.Pressed, TouchScreenButtonVisual.Released, TouchScreenButtonVisual.SettingsChanged, DevToolsBoard.DisableButtons, DevToolsBoard.NextPanel, DevToolsBoard.PreviousPanel, DevToolsBoard.SafeSubscribe, DevToolsBoard.ToggleConsole, RecentPlayersPage.OnPageBackwards, RecentPlayersPage.OnPageForward, RecentPlayersPage.RefreshList, GymnasiumTeleportPointPage.OnPageBackwards, GymnasiumTeleportPointPage.OnPageForward, RecentPlayerActionPage.banButton, RecentPlayerActionPage.muteButton, RecentPlayerActionPage.ToggleMute, RecentPlayerActionPage.unbanButton, RecentPlayerActionPage.unmuteButton.