One way to create XML data structures from game objects and properties is by hand-coding a method to create each element and its content, using the XMLWriter class.
Creating XML text data manually using XMLWriter
How to do it...
To create XML text data using XMLWriter, follow these steps:
- Create a C# CreateXMLString script class to add an instance as a component to the Main Camera:
using UnityEngine;
using System.Xml;
using System.IO;
public class CreateXMLString : MonoBehaviour {
private void Start () {
string output = BuildXMLString();
print(output);
}
private string BuildXMLString() {
StringWriter str = new StringWriter();
XmlTextWriter xml = new XmlTextWriter(str);
...