UI Controller

Presented by IUIController interface, this system provides pretty wide range of functionality which help to handle different game UI parts, display message boxes, dialogs, etc.

To use this system, inject IUIController interface into your class, as shown below:

[Inject] private IUIController uiController;

Parameters in inspector

currencySlotPrefab – prefab of UI currency slot.

currenciesHolder – transform inside the UI canvas, which contains currency slots.

levelLabel – text label which indicates current player's level.

expBar – player experience bar.

Available methods

Message Boxes

void ShowMessageBox(string title, string message, bool pauseGame = false)

This method shows message box with certain title and message. It also pauses the game, if pauseGame flag set to true.

Example:

uiController.ShowMessageBox("Warning", "Not enough money!");

void ShowMessageBox(string title, string message, string buttonText, UnityAction buttonCallback, bool pauseGame = false)

This method shows message box with certain title, message and buttonText on button. It also pauses the game, if pauseGame flag set to true. Also, buttonCallback is invoked if user clicks message box button.

Example:

uiController.ShowMessageBox("Warning", "Internet connection lost!", "OK", GoToMainMenu, true);

void ShowMessageBox(string title, string message, bool pauseGame, params MessageBoxButton[] buttons)

This method shows message box with certain title, message and buttons described by buttons parameters array.

Example:

uiController.ShowMessageBox("Warning", "Internet connection lost!", 
	new MessageBoxButton{ text = "OK", callback = GoToMainMenu },
	new MessageBoxButton{ text = "Reconnect", callback = Reconnect }, true);

Dialogs

void ShowDialog(DialogPopupMode dialogPopupMode, string message, Sprite avatarSprite, UnityAction closeCallback = null, float appearanceTime = 1f)

This method shows dialog with message, certain dialogPopupMode and avatarSprite (which visually represents character who says that message to player). Dialog appears in amount of time set by appearanceTime parameter and invokes closeCallback right after dialog closing.

Example:

uiController.ShowDialog(DialogPopupMode.Fullscreen, "Greetings, hero! What do you want to buy today?", null, OpenShop);

void ShowDialog(DialogPopupMode dialogPopupMode, string message, Transform targetTransform, float targetDistance, UnityAction closeCallback = null, float appearanceTime = 1f)

This method shows dialog with message, certain dialogPopupMode and targetTransform (camera will be targeted to this transform from targetDistance). Dialog appears in amount of time set by appearanceTime parameter and invokes closeCallback right after dialog closing.

Example:

uiController.ShowDialog(DialogPopupMode.Fullscreen, localizationManager.GetLocalizedString("DuelIntroDialogMsg"), enemyTransform, 1f, ShowSkills);

void ShowDialog(DialogPopupMode dialogPopupMode, string message, Sprite avatarSprite, AudioClip sound, UnityAction closeCallback = null, float appearanceTime = 1f)

This method shows dialog with message, certain dialogPopupMode and avatarSprite (which visually represents character who says that message to player). Dialog appears in amount of time set by appearanceTime parameter, plays certain sound and invokes closeCallback right after dialog closing.

This method could be useful if you need to accompany text message with its voice representation.


Last updated