Pause Menu

An example implementation that you can use directly or as a starting point. You can refer to the demo game samples to see it in action.

PauseMenuView

Base class with buttons:

  • Continue

  • Load

  • Settings

  • Main Menu

  • Quit

Example Implementation

public class PauseMenuViewExample : PauseMenuView
{
  [Header("Prefab Keys")]
  [SerializeField] string _settingsMenuKey = "Settings";
  [SerializeField] string _loadMenuKey = "SaveLoad";
  [Header("Main Menu Scene")]
  [SerializeField] string _mainMenuSceneKey = "MainMenu";

  private void OnButtonContinueClicked()
  {
    FadeOutThenDestroy();
  }

  protected override void OnButtonLoadGameClicked()
  {
    // Instantiate prefab
    UIPrefabLoaderString.Instance.Instantiate(_loadMenuKey);
  }

  protected override void OnButtonSettingsClicked()
  {
    // Instantiate prefab
    UIPrefabLoaderString.Instance.Instantiate(_settingsMenuKey);
  }

  protected override void OnButtonMainMenuClicked()
  {
    // Load MainMenu scene
    SceneLoader.Instance.LoadScene(_mainMenuSceneKey, SceneTransitionManager.Instance.Transitions.Dictionary["Fade"]);
  }

  protected override void OnButtonQuitGameClicked()
  {
    Application.Quit();
  }
}

Last updated