Posts: 436
Thanks: 976 in 6 Posts
UserSettings MySettings = new UserSettings (); string serialized = MySettings.ToExportString(); //saves/serializes the Data of MySettings into the string serialized
public interface ICustomSerializer
{
void Serialize(object objecttoserialize, BindingFlags flags, int Rekursion, Export_Import.SerializationData sData);
object Deserialize(Type objectType, string source, int Rekursion, Export_Import.SerializationData sData);
}
public class Vector3_Serializer : ICustomSerializer
{
public void Serialize(object objecttoserialize, BindingFlags flags, int Rekursion, Export_Import.SerializationData sData)
{
Vector3 v = ((Vector3)objecttoserialize); //cast the object to Vector3
sData.mExportString.Append(v.x+","+v.y+","+v.z); //add the important information x, y ,z to our Exportstring and seperate them with ","
}
public object Deserialize(Type objectType, string source, int Rekursion, Export_Import.SerializationData sData)
{
string[] result = source.Split(','); //get the data seperated by ","
return new Vector3(float.Parse(result[0]),float.Parse(result[1]) ,float.Parse(result[2])); //Create a new Vector with the 3 Axis values x,y,z
}
}