Example #1
0
 public void Load(ISaveable saveable)
 {
     if (IsRegistered(saveable))
     {
         string saveString = storage?.GetString(saveable.SaveKey, string.Empty);
         if (string.IsNullOrEmpty(saveString))
         {
             saveable.LoadDefaults();
         }
         else
         {
             try {
                 object save = JsonConvert.DeserializeObject(saveString, saveable.SaveType);
                 saveable.LoadSave(save);
             } catch (System.Exception exception) {
                 UDebug.LogError(exception.Message);
                 saveable.LoadDefaults();
             }
         }
     }
     else
     {
         throw new UnityException($"Load: saveable of type => {saveable.GetType().Name} is not registered on ISaveService");
     }
 }