Skip to main content

PopupManager

A class in Root.Township, the global namespace.

Client: singleton that shows popup boards one at a time from a static queue. Call a static Show overload from anywhere; it queues until the manager exists and the current popup closes.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private Transform controlParentTransform popups are spawned under.
private PopupBoard defaultBoardBoard prefab used when a popup has none of its own.
private static readonly Logger loggerNLog logger for popup activity.
private static readonly Queue<PopupManager.IPopupConfig> popupQueueStatic queue of popups waiting to show.

Properties​

MemberWhat it is
IPopupBoard CurrentPopup { get; private set; }The popup on screen, or null.

Methods​

MemberWhat it is
static PopupManager.IPopupConfig Show(IPopupBoard popup)Queues a popup (a given board, or the default one with a title and message or a setup callback) and returns its config, which can cancel it.
static PopupManager.IPopupConfig Show(string title, string message)Queues a popup (a given board, or the default one with a title and message or a setup callback) and returns its config, which can cancel it.
static PopupManager.IPopupConfig Show(IPopupBoard popup, string title, string message)Queues a popup (a given board, or the default one with a title and message or a setup callback) and returns its config, which can cancel it.
static PopupManager.IPopupConfig Show(Action<IPopupBoard> onSpawn)Queues a popup (a given board, or the default one with a title and message or a setup callback) and returns its config, which can cancel it.
static PopupManager.IPopupConfig Show(IPopupBoard popup, Action<IPopupBoard> onSpawn)Queues a popup (a given board, or the default one with a title and message or a setup callback) and returns its config, which can cancel it.
4 private and internal methods
MemberWhat it is
private void OnPopupClosed(IPopupBoard popup)When the current popup closes, clears it and shows the next queued one.
private void ProcessQueue()Shows the next queued popup that hasn't been cancelled.
private void ShowPopup(PopupManager.IPopupConfig popupConfig)Spawns a popup under controlParent and makes it current.
private void Start()Shows anything queued before the manager existed.