O'Reilly logo

Unity Game Development Scripting by Kyle D'Aoust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required