Default

Summary: Get the shared save service used by the static API.

Description

Use API.Default to access the shared SaveService instance. The static API forwards its calls to this instance. Subscribe to its events to observe save and load operations.

Declaration

C#
public static SaveService Default { get; }

Returns

The shared SaveService instance.

Example

Create WatchSaveCompletion.cs and attach it to an active GameObject. Use it alongside either Save example. It logs the result of each save made through the shared service.

C#
using Gley.SaveSystem;
using UnityEngine;

public class WatchSaveCompletion : MonoBehaviour
{
    private SaveService _service;

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

    private void OnSaved(SaveEventInfo info, SaveResult result)
    {
        Debug.Log($"{info.Name}: {result.Status}", this);
    }

    private void OnDisable()
    {
        _service.SaveCompleted -= OnSaved;
    }
}
On This Page