//XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX //================================================================================================ // SAVE THE DATA TO THE XML FILE public void Save() { path = getPath(); XmlDocument xmlDoc = new XmlDocument(); XmlElement elmRoot = xmlDoc.CreateElement("Data"); xmlDoc.AppendChild(elmRoot); for (int i = 0; i < allGameObjects.Count; i++) { // CHECK FOR THE TYPE OF THE OBJECT BEFOR SAVE INTO XML FILE XmlElement Current_Object; if (allGameObjects [i].tag == "cube") { // CREATING AN XML ELEMENT WITH CUBE Current_Object = xmlDoc.CreateElement("cube"); } else if (allGameObjects [i].tag == "capsule") { //CREATING AN XML ELEMENT WITH CUBE Current_Object = xmlDoc.CreateElement("capsule"); } else if (allGameObjects [i].tag == "cylinder") { //CREATING AN XML ELEMENT WITH CUBE Current_Object = xmlDoc.CreateElement("cylinder"); } else if (allGameObjects [i].tag == "sphere") { //CREATING AN XML ELEMENT WITH CUBE Current_Object = xmlDoc.CreateElement("sphere"); } else { // CREATE AN XML ELEMENT WITH EMPTY Current_Object = xmlDoc.CreateElement("empty"); } //CREATING AN XML ELEMENT FOR SAVING OBJECT NAME. XmlElement Current_Obj_Name = xmlDoc.CreateElement("name"); Current_Obj_Name.InnerText = allGameObjects [i].name; // CREATING AN XML ELEMENT FOR SAVING OBJECT POSITION. XmlElement Current_Obj_Position = xmlDoc.CreateElement("position"); // CREATING AN XML ELEMENT FOR SAVING POSITION'S X-AXIS VALUE. XmlElement Current_Position_x = xmlDoc.CreateElement("x"); Current_Position_x.InnerText = allGameObjects [i].transform.position.x + ""; // CREATING AN XML ELEMENT FOR SAVING POSITION'S Y-AXIS VALUE. XmlElement Current_Position_y = xmlDoc.CreateElement("y"); Current_Position_y.InnerText = allGameObjects [i].transform.position.y + ""; //CREATING AN XML ELEMENT FOR SAVING POSITION'S Z-AXIS VALUE. XmlElement Current_Position_z = xmlDoc.CreateElement("z"); Current_Position_z.InnerText = allGameObjects [i].transform.position.z + ""; Current_Obj_Position.AppendChild(Current_Position_x); Current_Obj_Position.AppendChild(Current_Position_y); Current_Obj_Position.AppendChild(Current_Position_z); // CREATING AN XML ELEMENT FOR SAVING OBJECT SCALE. XmlElement Current_Obj_Scale = xmlDoc.CreateElement("scale"); //CREATING AN XML ELEMENT FOR SAVING SCALE'S X-AXIS VALUE. XmlElement Current_Scale_x = xmlDoc.CreateElement("x"); Current_Scale_x.InnerText = allGameObjects [i].transform.localScale.x + ""; //CREATING AN XML ELEMENT FOR SAVING SCALE'S Y-AXIS VALUE. XmlElement Current_Scale_y = xmlDoc.CreateElement("y"); Current_Scale_y.InnerText = allGameObjects [i].transform.localScale.y + ""; //CREATING AN XML ELEMENT FOR SAVING SCALE'S Z-AXIS VALUE. XmlElement Current_Scale_z = xmlDoc.CreateElement("z"); Current_Scale_z.InnerText = allGameObjects [i].transform.localScale.z + ""; Current_Obj_Scale.AppendChild(Current_Scale_x); Current_Obj_Scale.AppendChild(Current_Scale_y); Current_Obj_Scale.AppendChild(Current_Scale_z); // CREATING AN XML ELEMENT FOR SAVING TAG OF THE OBJECT XmlElement Current_Tag = xmlDoc.CreateElement("tag"); Current_Tag.InnerText = allGameObjects [i].tag; Current_Object.AppendChild(Current_Obj_Name); Current_Object.AppendChild(Current_Obj_Position); Current_Object.AppendChild(Current_Obj_Scale); Current_Object.AppendChild(Current_Tag); elmRoot.AppendChild(Current_Object); } StreamWriter outStream = System.IO.File.CreateText(path); xmlDoc.Save(outStream); outStream.Close(); popupMessage.text = "Data Saved Successfully !!!"; StartCoroutine(DisplayMessage()); }
public SceneContainer GetContainer() { return(Current_Object.Clone() as SceneContainer); }
public SceneContainer GetContainer() => Current_Object.Clone() as SceneContainer;