- Home /
Why does my vector3 inside a custom class not serialize?
So I am trying to serialize information from a game I am running back out to an xml file. This information is then loaded when you run the application the next time. I wrote a custom class to store the gameobject, component and field/property that the new data should be saved from and loaded to. That part works fine. Now the problem I am having is in the storage of the actual value. I have a newValue variable that is of type "object" so that it can be used to save many types of data. It works great for primitive types, but if I try to save a Vector3 it fails. I found out that I can get it to work by putting a Vector3 variable somewhere else in my custom class so that it will serialize before my newValue variable. Why would this allow the newValue variable to be serialized with a Vector3? Is there some way I can tell the serializer that there will be a Vector3 in my class, with XmlType or something similar?