SaveCompleted

Summary: Reports the result when a named save finishes.

Description

Reports the result when a named save finishes. The result can describe a success or a failure. The event is raised on Unity’s main thread for both synchronous and asynchronous saves. Subscribe on API.Default to observe calls through the static API.

Declaration

C#
public event Action<SaveEventInfo, SaveResult> SaveCompleted;

Parameters

Handler argumentTypeDescription
infoSaveEventInfoThe name and slot of the save.
resultSaveResultThe outcome of the save. Check IsSuccess or inspect Status and Message.

Example

Create WatchSaveCompleted.cs. Attach this component beside either Save example and enter Play mode. The Console prints the outcome for each save.

C#
using Gley.SaveSystem;
using UnityEngine;

public class WatchSaveCompleted : MonoBehaviour
{
    private SaveService _service;

    private void OnEnable()
    {
        _service = API.Default;
        _service.SaveCompleted += OnSaveCompleted;
    }

    private void OnDisable()
    {
        _service.SaveCompleted -= OnSaveCompleted;
    }

    private void OnSaveCompleted(SaveEventInfo info, SaveResult result)
    {
        Debug.Log($"Save {info.Slot}/{info.Name}: {result.Status}", this);
    }
}
On This Page