Essential Systems / UI Manager

UI Manager

Enjoying Essential Systems?Leave a review

Learn to use the included UI manager.

UIManager

Use when you want to show and hide a UI panel.

public class TestUIManager : UIManager<TestUIManager>
{
    public override void Show()
    {
        // show logic
    }

    public override void Hide()
    {
        // hide logic
    }
}

UIStateManager

Use when a UI panel has multiple states, each with its own content. Define your states as an enum and handle each in OnStateChanged().

public enum EPauseUI { Asleep, Main, Options }

public class PauseUIManager : UIStateManager<PauseUIManager, EPauseUI>
{
    protected override EPauseUI SleepState => EPauseUI.Asleep;
    protected override EPauseUI InitState => EPauseUI.Main;

    protected override void OnStateChanged()
    {
        switch (State)
        {
            case EPauseUI.Asleep: break;
            case EPauseUI.Main: break;
            case EPauseUI.Options: break;
        }
    }

    public override void Show()
    {
        Pause(true);
        base.Show();
    }

    public override void Hide()
    {
        Unpause();
        base.Hide();
    }
}

SleepState is the inactive state. InitState is the state the panel opens in. Calling base.OnStateChanged() automatically enables the correct panel for the current state.

Last updated