- Home /
Question by
Zimbwawa · Mar 02, 2019 at 07:59 AM ·
xmlxmlserializer
Why am I getting an error when I serialize with XML?
The error is
InvalidOperationException: To be XML serializable, types which inherit from IEnumerable must have an implementation of Add(System.Object) at all levels of their inheritance hierarchy. UnityEngine.Transform does not implement Add(System.Object).
My code is
void Save()
{
XmlSerializer serializer = new XmlSerializer(typeof(HealthScript));
FileStream stream = new FileStream(Application.dataPath, FileMode.Create);
serializer.Serialize(stream, gameObject);
stream.Close();
}
Can you please explain what the error means and how to fix it? Thanks in advance.
Comment