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.
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();
}
}