private void SaveDatum(ES3File saveFile, BaseVariable variable) { string saveKey = variable.Name; if (variable is IntVariable intVar) { saveFile.Save <int>(saveKey, intVar.Value); } else if (variable is FloatVariable floatVar) { saveFile.Save <float>(saveKey, floatVar.Value); } else if (variable is StringVariable stringVar) { saveFile.Save <string>(saveKey, stringVar.Value); } else if (variable is BoolVariable boolVar) { saveFile.Save <bool>(saveKey, boolVar.Value); } else { Debug.LogWarning("[ScriptableObjectSaveSystem]" + " Save Type not implemented. " + "Rich is just being lazy."); } }
public void TrySave <T>(string key, T value, bool isLocal = false) { ES3File targetFile = null; if (!isLocal) { targetFile = file; } else { targetFile = localFile; } if (targetFile == null) { return; } try { targetFile.Save <T>(key, value); } catch (System.Exception e) { UnityEngine.Debug.LogException(e); } }
/* User-facing methods used when writing randomly-accessible Key-Value pairs. */ #region Write(key, value) Methods /// <summary>Writes a value to the writer with the given key.</summary> /// <param name="key">The key which uniquely identifies this value.</param> /// <param name="value">The value we want to write.</param> public override void Write <T>(string key, object value) { es3File.Save <T>(key, (T)value); }