Coding Patterns Example
ESave Pro supports multiple coding patterns including synchronous, asynchronous, and callbacks. Here you can find examples for each coding pattern so that you can compare the differences and determine which one is best for your use case.
Each example does the exact same thing in a different way. Here's what the code is doing in order of operations:
Create a save state
Load the save state
Save a string to the save state
Load the string from the save state and log it in the console
Synchronous
Multithread mode must be disabled for synchronous coding.
/// <summary>
/// Synchronous example. Multithread mode must be disabled.
/// </summary>
public void SynchronousExample()
{
// Create save (if the save is already created, it's simply returned)
var mySave = ESave.CreateSave(0).Result;
// Load save (set as active)
// You can also load it by it's ID: ESave.Load(0)
ESave.Load(mySave);
// Add data
mySave.AddData("MyDataID", "some string");
// Load data and debug it
var myData = mySave.GetData<string>("MyDataID").Result;
Debug.Log(myData);
}Asynchronous
Works in all multithread modes, but is meant for modes other than disabled.
Callbacks
Works in all multithread modes, but is meant for modes other than disabled.
Last updated