-
Notifications
You must be signed in to change notification settings - Fork 0
Save and Load SocialEngine State
Shi Johnson-Bey edited this page Feb 21, 2024
·
3 revisions
TDRS provides the TdrsJsonExporter
and TdrsJsonImporter
classes to save and load the social engine's state to and from JSON strings.
using TDRS.Serialization;
using UnityEngine;
// A MonoBehaviour class that saves and loads the engine state
public class SaveManager : MonoBehaviour
{
public void HandleCreateSave()
{
var socialEngine = SocialEngineController.Instance.State;
var jsonExporter = new TdrsJsonExporter();
string jsonString = jsonExporter.Export(socialEngine);
// Save jsonString to file in the persistent data path
}
public void HandleLoadSave()
{
var socialEngineController = SocialEngineController.Instance;
var jsonImporter = new TdrsJsonImporter();
string jsonString = "Load json data from somewhere";
SocialEngine socialEngine = jsonImporter.Import(jsonString);
socialEngineController.State = socialEngine;
}
}