flagEvents System

You can subscribe to save & load events for custom logic. It does not matter whether you approach Save & Load through the Code Mode or the No-Code Mode, Events are available for both, whenever Save or Load operations trigger, independently of the source.

Events

using cowsins.OmniSave.Runtime.Core;

SaveService.OnSaveStarted += OnSaveStarted;
SaveService.OnSaveProgress += OnSaveProgress;
SaveService.OnSaveCompleted += OnSaveCompleted;
SaveService.OnLoadStarted += OnLoadStarted;
SaveService.OnLoadProgress += OnLoadProgress;
SaveService.OnLoadCompleted += OnLoadCompleted;

Events Architecture

void OnSaveStarted(int slotIndex) { }
void OnSaveProgress(int slotIndex, float progress) { } // 0f to 1f
void OnSaveCompleted(int slotIndex, bool success) { }

void OnLoadStarted(int slotIndex) { }
void OnLoadProgress(int slotIndex, float progress) { } // 0f to 1f
void OnLoadCompleted(int slotIndex, bool success) { }

Practical Example: Loading Bar

Saveable Component Events

Each Saveable component has Unity Events:

  • onBeforeSave

  • onAfterSave

  • onBeforeLoad

  • onAfterLoad

Assign in inspector or via code:


Last updated