I need a small pointer for using a custom Type in EasySave 3. I have previously used EasySave 2 around 18 months ago using this method but I don't seem to be able to get EasySave 3 to work in the same way.
I have created a custom class to use as my type:
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StartPlotCust
{
public string plotName {get; set;}
public string cropName {get; set;}
public bool isPlanted {get; set;}
public bool startGrowing {get; set;}
public float harvestTimer {get; set;}
public int growStage {get; set;}
}
I am using this type with ES3.Save as follows:
Code: Select all
public List<StartPlotCust> startPlotCustList = new List<StartPlotCust> ();
...
foreach (Transform t in startPlots.transform) {
startPlotCustList.Add(new StartPlotCust {plotName = t.name, cropName = t.GetChild(0).transform.name, isPlanted = t.GetComponent<GrowController>().isPlanted, startGrowing = t.GetComponent<GrowController>().startGrowing, harvestTimer = t.GetComponent<GrowController>().harvestTimer, growStage = t.GetComponent<GrowController>().growStage});
}
...
ES3.Save<StartPlotCust>("startPlots", startPlotCustList);
Code: Select all
startPlotCustList = ES3.Load<List<StartPlotCust>>("startPlots"); // Load the list
InvalidOperationException: Trying to load data of type System.Collections.Generic.List`1[StartPlotCust], but data contained in file is type of StartPlotCust.
ES3Reader.ReadTypeFromHeader[T] () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:273)
ES3Reader.Read[T] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:160)
ES3.Load[T] (System.String key, ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:269)
ES3.Load[T] (System.String key) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:240)
Am I missing something in the way I have added the custom type? From memory and looking back through my old scripts this was how I implemented ES2 in a previous project but I am perhaps missing something really simple...usually the way.
Any pointers would be very much appreciated!
Many thanks,
Stephen.