SaveOptions

Summary: Select a slot for a save or load, or override protection and compression when saving.

Description

Pass a SaveOptions instance to choose the slot for one call. On a write, you can also override the project’s protection and compression settings. A null options argument uses the default slot and the configured write settings.

Namespace Gley.SaveSystem.

Declaration

C#
public class SaveOptions

Members

MemberTypeDescription
SlotstringSlot name. A null value uses the default slot.
Protectbool?Controls protection when writing. A null value uses the active platform’s setting.
Compressbool?Controls compression when writing. A null value uses the active platform’s setting.

Example

Create SavePositionInProfile.cs, attach it to a GameObject and enter Play mode. This writes the position to profile1. Use the same slot when you load it.

C#
using Gley.SaveSystem;
using UnityEngine;

public class SavePositionInProfile : MonoBehaviour
{
    private void Start()
    {
        SaveOptions options = new SaveOptions { Slot = "profile1" };
        SaveResult result = API.Save(transform.position, "type-reference-position", options);
        Debug.Log($"Save status: {result.Status}", this);
    }
}
On This Page