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.
using CupkekGames.Core;
using UnityEngine;
public class MainMenuViewExample : MainMenuView<GameSaveDataExample>
{
[Header("Prefab Keys")]
[SerializeField] string _settingsMenuKey = "Settings";
[SerializeField] string _loadMenuKey = "SaveLoad";
[SerializeField] string _gameScene = "Base";
protected override GameSaveManager<GameSaveDataExample> GetSaveManager()
{
return (GameSaveManagerExample)GameSaveManagerExample.Instance;
}
protected override void OnButtonContinueClicked()
{
GameSaveManager.CurrentSave.Data = LastSave;
SceneLoader.Instance.LoadScene(_gameScene, SceneTransitionManager.Instance.Transitions.Dictionary["Fade"]);
}
protected override void OnButtonLoadClicked()
{
UIPrefabLoaderString.Instance.Instantiate(_loadMenuKey);
}
protected override void OnButtonNewGameClicked()
{
_buttonNewGame.SetEnabled(false);
GameSaveManager.CurrentSave.Data = new GameSaveDataExample();
SceneLoader.Instance.LoadScene(_gameScene, SceneTransitionManager.Instance.Transitions.Dictionary["Fade"]);
}
protected override void OnButtonCreditsClicked()
{
Debug.Log("Credits");
}
protected override void OnButtonSettingsClicked()
{
UIPrefabLoaderString.Instance.Instantiate(_settingsMenuKey);
}
}