It was necessary to implement the saving and loading of a variable in a unit via serialization (when you press the "S" key, it must be saved, and when you press "L" it is loaded).

The Xml file should look like this:

<Scene1> <x>0</x> </Scene1> 

Tell me, please, how to do it.

    1 answer 1

    If the problem is how to work with XML files, then I will give an example in C #.

    Create a Scene class:

     public class Scene { public int x { get; set; } } 

    Now you can create a script to work with XML.

     using System.Xml.Serialization; public class WorkWithXML { public void Save(Scene sceneForSave) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(Scene)); using (TextWriter writer = new StreamWriter("Scene.xml")) { serializer.Serialize(writer, sceneForSave); } } public Scene Load() { StreamReader reader = new StreamReader("Scene.xml"); Scene loadedScene = (Scene)serializer.Deserialize(reader); reader.Close(); return loadedScene; } } 

    In the right place in the code, call these methods by creating an instance of the WorkWithXML class or simply by making these methods static. I hope this is the appropriate answer to your question.