Hi there,
The simplest way is to add a parameterless constructor to your class so it will be automatically supported. However, if this isn't possible, this is covered in the
Manually Modifying an ES3Type section here. However, I'll provide a bit more detail for you.
The template ES3Type file can be generated by going to
Window > Easy Save 3 > Types, typing the name of the type into the search field (this is case sensitive), and then selecting the fields that you want to be saved. The ES3Type can then be found in
Assets/Easy Save 3/Types/ES3Type_<YOUR TYPE NAME>.cs
Once you open this, you will want to modify the ReadObject<T>(ES3Reader reader) method so that it creates the instance of your class. This method shouldn't be mistaken for the
ReadObject<T>(ES3Reader reader, object obj) method. So let's say that we're adding support for ClassA, and it has a constructor which accepts ClassB as a parameter. This might look like this:
protected override object ReadObject<T>(ES3Reader reader)
{
var classB = new ClassB()
var instance = new ClassA( classB );
ReadObject<T>(reader, instance);
return instance;
}
Or if you need to load ClassB before loading ClassA, you can simply save ClassB separately and load it so that we can use it as the parameter in the constructor. E.g.
protected override object ReadObject<T>(ES3Reader reader)
{
var classB = ES3.Load<ClassB>("classBKey");
var instance = new ClassA( classB );
ReadObject<T>(reader, instance);
return instance;
}
Easy Save will automatically detect the ES3Type class, so then you can save and load your class the same way as you would with any other data. i.e.
ES3.Save<ClassB>("classBKey", classB);
ES3.Save<ClassA>("classAKey", classA);
classA = ES3.Load<ClassA>("classAKey");
Hope this helps.
All the best,
Joel