Loading data with XML
Our final step in learning how to use XML is to load the data that we just saved to our XML document into our game. While loading the XML data, you will notice that it's a process similar to that of loading from a flat file. The real difference is that instead of loading a line of data, we are loading from a specific part of the saved data.
Loading the player data
To load player data, we will add this function to your script just below the SavePlayer
function and above the SaveEnemies
function:
void LoadPlayer() { float xPos = 0.00f; float yPos = 0.00f; float zPos = 0.00f; float xRot = 0.00f; float yRot = 0.00f; float zRot = 0.00f; float xScale = 0.00f; float yScale = 0.00f; float zScale = 0.00f; if(Player != null) { XmlNode root = xPlayer.FirstChild; foreach(XmlNode node in root.ChildNodes) { switch(node.Name) { case "xPos": xPos = Convert.ToSingle(node.InnerText); break; case "yPos": ...