ESave
ESave Pro
ESave Pro
  • ESave Pro Documentation
  • Pro Comparison
  • đŸ•šī¸Getting Started
    • Installation
    • Demo
  • ESave Settings
  • 🧩Components
    • ESave Initializer
  • 📄Scripting
    • Initialization
    • Save Operation
    • Save States
      • Infinite Saves
        • Infinite Save Scripting
    • Saving & Loading Data
      • Saving
      • Loading
      • Custom Serializable Objects
      • Example Script
    • Data Deletion
  • đŸ› ī¸Support
    • Getting Help
  • 📚Changelogs
    • Latest Releases
  • ⭐Rate Me?
Powered by GitBook
On this page
  • 1. Getting the Save State
  • 2. Loading Data
  • Getting Data
  • Special Methods
  1. Scripting
  2. Saving & Loading Data

Loading

This section outlines the step-by-step process of loading data using ESave.

1. Getting the Save State

The first step to saving data is loading the save state. You will need a save state ID. See Save States for more information.

SaveState saveState = ESave.GetSaveState(mySaveStateID);

2. Loading Data

Each ESave method that loads data only accepts one parameter, which is the ID of the data.

Getting Data

The main method to load data is saveState.GetData. This method accepts any type as a parameter.

// Where T is the data type
saveState.GetData<T>("DataID").OnComplete(result =>
{
    Debug.Log(result);
});

This method returns a Save Operation (result type: T).

You can also retrieve a list of data of the same type:

// Where T is the data type
saveState.GetData<T>("DataID", "DataID2", "DataID3").OnComplete(result =>
{
    Debug.Log(result.Count);
});

This method returns a Save Operation (result type: List<T>).

Special Methods

ESave features special methods to retrieve data for some Unity types.

Vector2

saveState.GetVector2("DataID").OnComplete(v2 => Debug.Log(v2));

Vector3

saveState.GetVector3("DataID").OnComplete(v3 => Debug.Log(v3));

Quaternion

saveState.GetQuaternion("DataID").OnComplete(q => Debug.Log(q));

Color

saveState.GetColor("DataID").OnComplete(c => Debug.Log(c));

Transform

// Returns a SavableTransform
saveState.GetTransform("DataID").OnComplete(st =>
{
    // Set position and rotation
    transform.SetPositionAndRotation(st.Position, st.Rotation);
});

RectTransform

saveState.GetRectTransform("DataID").OnComplete(srt =>
{
    // Set anchored position, size, and rotation
    var rectTransform = transform as RectTransform;
    rectTransform.anchoredPosition = srt.AnchoredPosition;
    rectTransform.sizeDelta = srt.SizeDelta;
    rectTransform.rotation = srt.Rotation;
});
PreviousSavingNextCustom Serializable Objects

Last updated 2 months ago

📄