SlotInfo

Summary: Read the save names and metadata reported for a slot.

Description

ListSlots returns a snapshot for each existing slot. Cache the result for menus and refresh it after a change to the slots.

Namespace Gley.SaveSystem.

Declaration

C#
public class SlotInfo

Members

MemberTypeDescription
NamestringName of the slot.
KeysIReadOnlyList<string>Save names in the slot.
CustomIReadOnlyDictionary<string, string>Custom metadata entries.
LastSavedUtcDateTimeLast recorded save time in UTC, or DateTime.MinValue when unavailable.
SaveCountintNumber of saves recorded in the slot metadata. Use Keys.Count for the number of names in this snapshot.

Example

Create ReadSlotInfo.cs, attach it to a GameObject and enter Play mode. Create a save first to see a slot in the Console.

C#
using System.Collections.Generic;
using Gley.SaveSystem;
using UnityEngine;

public class ReadSlotInfo : MonoBehaviour
{
    private void Start()
    {
        IReadOnlyList<SlotInfo> slots = API.ListSlots();
        foreach (SlotInfo slot in slots)
        {
            Debug.Log($"{slot.Name}: {slot.Keys.Count} saved entries", this);
        }
    }
}
On This Page