private void LoadDatum(ES3File saveFile, BaseVariable variable) { string saveKey = variable.Name; if (variable is IntVariable intVar) { intVar.Value = saveFile.Load <int>( saveKey, intVar.Value); } else if (variable is FloatVariable floatVar) { floatVar.Value = saveFile.Load <float>( saveKey, floatVar.Value); } else if (variable is BoolVariable boolVar) { boolVar.Value = saveFile.Load <bool>( saveKey, boolVar.Value); } else if (variable is StringVariable stringVar) { stringVar.Value = saveFile.Load <string>( saveKey, stringVar.Value); } else { Debug.LogWarning("[ScriptableObjectSaveSystem]" + " Save Type not implemented. " + "Rich is just being lazy."); } }
// Load single data public T TryLoad <T>(string key, T defaultValue = default(T), bool isLocal = false) { ES3File targetFile = null; if (!isLocal) { targetFile = file; } else { targetFile = localFile; } if (targetFile == null) { return(defaultValue); } if (!targetFile.KeyExists(key)) { return(defaultValue); } try { return(targetFile.Load <T>(key, defaultValue)); } catch (System.Exception e) { UnityEngine.Debug.LogException(e); return(defaultValue); } }