LoadCompleted

Summary: Reports the final status when a named load finishes.

Description

Reports the final status when a named load finishes. The event is raised on Unity’s main thread for both synchronous and asynchronous loads. When recovery succeeds, RecoveredFromBackup runs first. Read the LoadResult<T> from the load call or its callback to get the loaded data. Subscribe on API.Default to observe calls through the static API.

Declaration

C#
public event Action<SaveEventInfo, SaveStatus> LoadCompleted;

Parameters

Handler argumentTypeDescription
infoSaveEventInfoThe name and slot of the load.
statusSaveStatusThe final load status. Successful recovery reports Success.

Example

Create WatchLoadCompleted.cs. Attach this component beside either Load example and enter Play mode. The Console prints the load status.

C#
using Gley.SaveSystem;
using UnityEngine;

public class WatchLoadCompleted : MonoBehaviour
{
    private SaveService _service;

    private void OnEnable()
    {
        _service = API.Default;
        _service.LoadCompleted += OnLoadCompleted;
    }

    private void OnDisable()
    {
        _service.LoadCompleted -= OnLoadCompleted;
    }

    private void OnLoadCompleted(SaveEventInfo info, SaveStatus status)
    {
        Debug.Log($"Load {info.Slot}/{info.Name}: {status}", this);
    }
}
On This Page