Code: Select all
public class Person {
public string Name;
public int Age;
// providing two parameter constructor deletes implicit zero parameter constructor
public Person(string name, int age) {
Name = name;
Age = age;
}
}
public class MyTestBehaviour: MonoBehaviour {
public Dictionary<string, Person> MyPersonDictionary;
}
ES3.Save("MyTestBehaviour", testBehaviourInstance);
Silently discards the MyPersonDictionary field.
ES3.Save("MyPersonDictionary", MyPersonDictionary);
Throws exception with vague message: NotSupportedException: Types of System.Collections.Generic.Dictionary`2[System.String,Person] are not supported.
ES3.Save("MyPerson", personInstance);
Throws exception with helpful message: NotSupportedException: Type of Person is not supported as it does not have a parameterless constructor. Only value types, Components or ScriptableObjects are supportable without a parameterless constructor. However, you may be able to create an ES3Type script to add support for it.
i spent a long time debugging what was happening in my project with Dictionaries disappearing and sometimes throwing exceptions. i believe Easy Save 3 can be improved by always surfacing the helpful message you get if you try to serialize a Person directly.
thanks for your consideration