Exists

Summary: Check whether a named save exists in a slot.

Description

Check whether a named save exists in a slot. If the result is needed repeatedly, cache it and refresh it after a save or deletion.

Declaration

C#
public static bool Exists(string name, string slot = null);

Parameters

ParameterTypeDescription
namestringName of the save.
slotstringOptional. Slot to search in. Null uses the default slot.

Returns

True if a save exists.

Example

Create CheckSavedPosition.cs and attach it to an active GameObject. Run the synchronous Save example to create the sample save. This script checks once on entering Play mode.

C#
using Gley.SaveSystem;
using UnityEngine;

public class CheckSavedPosition : MonoBehaviour
{
    private void Start()
    {
        bool exists = API.Exists("position-sync-example");
        Debug.Log($"Position save exists: {exists}", this);
    }
}
On This Page