MainMenuView<TSaveData, TSaveMetadata> is an abstract UIViewComponent that wires up Continue / Load / New Game / Settings / Credits / Quit buttons. Continue and Load are auto-enabled based on whether a save exists, queried through the GameSave manager you provide.

Main Menu

Setup

  1. Build the UXML with these button names (the view does Q<Button>(...) lookups):
    • ButtonContinue
    • ButtonLoad
    • ButtonNewGame
    • ButtonCredits
    • ButtonSettings
    • ButtonQuit
  2. Subclass MainMenuView<TSaveData, TSaveMetadata> for your save types and implement GetSaveManager() plus the six OnButton...Clicked abstracts.
  3. Wire the GameSaveManager by returning your concrete manager from GetSaveManager().
csharp
public class MyMainMenuView : MainMenuView<MyGameSaveData, MyGameSaveMetadata> { [SerializeField] private MyGameSaveManager _saveManager; protected override GameSaveManager<MyGameSaveData, MyGameSaveMetadata> GetSaveManager() => _saveManager; protected override void OnButtonContinueClicked() => _saveManager.LoadFromSlot(LastSaveSlot, /* loadScene */ true); protected override void OnButtonLoadClicked() => OpenLoadView(); protected override void OnButtonNewGameClicked() => StartNewGame(); protected override void OnButtonCreditsClicked() => OpenCreditsView(); protected override void OnButtonSettingsClicked() => OpenSettingsView(); protected override void OnButtonQuitClicked() => Application.Quit(); }

API

Type signature:

csharp
namespace CupkekGames.Systems.UI; public abstract class MainMenuView<TSaveData, TSaveMetadata> : UIViewComponent where TSaveData : IGameSaveData, IData, new() where TSaveMetadata : GameSaveMetadata

Properties

PropertyTypeDescription
GameSaveManagerGameSaveManager<TSaveData, TSaveMetadata>The manager returned from GetSaveManager().
LastSaveMetadataTSaveMetadataMetadata for the most-recent save (null if none).
LastSaveSlotintSlot index of the most-recent save.

Protected fields

_buttonContinue, _buttonLoad, _buttonNewGame, _buttonCredits, _buttonSettings, _buttonQuit — the resolved Button instances. Available after Awake().

Methods (abstract — you implement)

MethodCalled when
GetSaveManager()Once during Awake() to fetch your GameSaveManager.
OnButtonContinueClicked()Continue button clicked.
OnButtonLoadClicked()Load button clicked.
OnButtonNewGameClicked()New Game button clicked.
OnButtonCreditsClicked()Credits button clicked.
OnButtonSettingsClicked()Settings button clicked.
OnButtonQuitClicked()Quit button clicked.

Methods (virtual — override to extend)

OnEnable() / OnDisable() — wire/unwire button handlers and set initial focus. If you override, call base.OnEnable() / base.OnDisable().

Behaviour

When the view awakens, GetSaveManager().GetLastMetadata() is called once. The result decides:

  • Save exists: _focusName = "ButtonContinue", Continue + Load enabled, Continue gets initial focus.
  • No save: _focusName = "ButtonNewGame", Continue + Load disabled, New Game gets initial focus.

See also

Settings

Theme

Light

Contrast

Material

Dark

Dim

Material Dark

System

Sidebar(Light & Contrast only)

Light
Dark

Font Family

DM Sans

Wix

Inclusive Sans

AR One Sans

Direction

LTR
RTL