SaveStarted

Summary: Runs when a named save starts, before the data is prepared.

Description

Runs when a named save starts, before the data is prepared. It runs before validation, so an attempt can raise this event and still fail. Use it to show that saving has started. SaveCompleted reports the result. Subscribe on API.Default to observe calls through the static API.

Declaration

C#
public event Action<SaveEventInfo> SaveStarted;

Parameters

Handler argumentTypeDescription
infoSaveEventInfoThe name and slot of the save.

Example

Create WatchSaveStarted.cs. Attach this component beside either Save example and enter Play mode. The Console prints the name and slot when a save begins.

C#
using Gley.SaveSystem;
using UnityEngine;

public class WatchSaveStarted : MonoBehaviour
{
    private SaveService _service;

    private void OnEnable()
    {
        _service = API.Default;
        _service.SaveStarted += OnSaveStarted;
    }

    private void OnDisable()
    {
        _service.SaveStarted -= OnSaveStarted;
    }

    private void OnSaveStarted(SaveEventInfo info)
    {
        Debug.Log($"Saving {info.Slot}/{info.Name}.", this);
    }
}
On This Page