Luna's save system framework provides UI components that work with any save implementation through a clean abstraction layer. Your UI remains unchanged whether you use JSON files, binary data, cloud storage, or encrypted saves.

Key Benefits: UI-agnostic design, pluggable save implementations, fast metadata loading, and seamless integration with Luna's UI components.

Core Concepts

UI Components

Luna provides pre-built UI components like MainMenuView and GameSaveView that handle save/load operations automatically.

GameSaveManager<TData,TMeta>

Abstract interface that connects your save implementation to Luna's UI. You provide the concrete implementation.

Save Data Types

Your game defines the save data structure (TSaveData) and metadata (TSaveMetadata) that the UI will work with.

The beauty of Luna's save system is that your UI code never changes. Whether you implement JSON files, binary data, cloud storage, or encrypted saves, the UI components work identically through the manager interface.

Quick Start

1. Define Your Save Data

Create your save data class that implements IGameSaveData:

csharp
public class MyGameSaveData : IGameSaveData { public GameSaveMetadata Metadata { get; set; } public string PlayerName; public int Gold; public Inventory Inventory; public MyGameSaveData() { PlayerName = "Player"; Gold = 0; Inventory = new Inventory(); } public GameSaveMetadata CreateMetadata(string saveVersion, bool isAutosave) { return new MyGameSaveMetadata { SaveVersion = saveVersion, SaveDate = DateTime.Now, IsAutosave = isAutosave, Gold = Gold, }; } public void LoadFrom(IGameSaveData other, int slot) { var o = (MyGameSaveData)other; Metadata = o.Metadata; PlayerName = o.PlayerName; Gold = o.Gold; Inventory = o.Inventory; } }

2. Create Metadata Class

Define lightweight metadata for UI display:

csharp
public class MyGameSaveMetadata : GameSaveMetadata { public int Gold; }

3. Implement Save Manager

Inherit from GameSaveManager<TSaveData, TSaveMetadata> and implement the required methods:

csharp
public class MyGameSaveManager : GameSaveManager<MyGameSaveData, MyGameSaveMetadata> { // Enumerate all save files protected override string[] GetAllFileNames() { // Your implementation here - could be files, cloud entries, etc. return Directory.GetFiles(GetSaveDirectory(), "*.sav") .Select(Path.GetFileName) .ToArray(); } // Create a new save instance protected override MyGameSaveData GetNewSave(string saveVersion) { return new MyGameSaveData(); } // Save data to storage protected override void OnSaveRequest(int saveSlot, string fileName, MyGameSaveData data, bool autosave) { // Your save implementation - could be JSON, binary, cloud, etc. // Example: File.WriteAllBytes(Path.Combine(GetSaveDirectory(), fileName), serializedData); } // Load full save data protected override MyGameSaveData LoadFromFile(string fileName) { // Your load implementation // Example: return DeserializeData(File.ReadAllBytes(...)); return null; } // Load only metadata (for fast UI loading) protected override MyGameSaveMetadata LoadMetadataFromFile(string fileName) { // Fast path to read only metadata without loading full save return null; } protected override string GetFileExtension() => "sav"; protected override string GetSaveVersion() => "1.0"; }

4. Connect to Luna UI

Wire your manager into Luna UI components by overriding the provider method:

csharp
public class MyMainMenuView : MainMenuView<MyGameSaveData, MyGameSaveMetadata> { [SerializeField] private MyGameSaveManager saveManager; protected override GameSaveManager<MyGameSaveData, MyGameSaveMetadata> GetSaveManager() { return saveManager; } }

Info: Once connected, UI buttons (Continue, Load, New Game, Delete) automatically work through your manager. No additional UI code needed!

Available UI Components

Provides Continue, New Game, and Load Game buttons. Automatically enables Continue when a recent save exists.

GameSaveView<TSaveData, TSaveMetadata>

Displays save slots with metadata previews, handles save/load/delete operations.

For detailed UI implementation examples, see: Main Menu and Save & Load views. Also available is the Autosave Notification utility UI.

Implementation Examples

Your save manager can implement any storage format. For a complete working example with Newtonsoft JSON, see:

Info: Refer to Newtonsoft JSON Sample for a complete working implementation with serializer initialization, converters, and file handling.

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