Game Development Reference
In-Depth Information
004 using System.Collections.Generic;
005 using System.Xml;
006 using System.Xml.Serialization;
007 using System.Runtime.Serialization.Formatters.Binary;
008 using System.IO;
009 //-----------------------------------------------
010 public class ObjSerializer : MonoBehaviour
011 {
012 //Data to save to file XML or Binary
013 [System.Serializable]
014 [XmlRoot("GameData")]
015 public class MySaveData
016 {
017 //Transform data to save/load to and from file
018 //represents a conversion of a transform object
019 //into simpler values, like floats
020 [System.Serializable]
021 public struct DataTransform
022 {
023 public float X;
024 public float Y;
025 public float Z;
026 public float RotX;
027 public float RotY;
028 public float RotZ;
029 public float ScaleX;
030 public float ScaleY;
031 public float ScaleZ;
032 }
033
034 //Transform object to save
035 public DataTransform MyTransform = new DataTransform();
036 }
037
038 //My Save Data Object declared here
039 public MySaveData MyData = new MySaveData();
040 //-----------------------------------------------
041 //Populate structure MyData with transform data
042 //This is the data to be saved to a file
043 private void GetTransform()
044 {
 
Search WWH ::




Custom Search