XML
Since I happen to be ranked somewhat high when it comes to mentioning Unity 3D and XML, and some of the posts1 happen to be outdated by now since I learned stuff2. But most of all, I intend to learn even more.
That's why I choose to release those two projects into the wild and publish them on github.
-
Like the one on writing log files in Unity 3D or the one on getting strings out of XML files. ↩
-
Yes, that happens from time to time. ↩
Since I already played around with XML in C#, this part of the project was easier to do than before.
What is it supposed to do?
Basically, I could simply hard-code most of my strings used in the game directly into the code – no one would notice the difference anyway. But obviously, this is not a very good idea, both because editing strings and later translating them becomes a pain.
Creating some data that would allow me to get strings out of an XML file would solve this problem – and, if the code is good enough, be reusable in later games.
It would allow me to edit text independently of the game code and add translations on a later date.
Since I want to make some basic statistics for my game at Fantoche, I needed some basic logging function of the player's position.
Of course, this could also be done using a simple CSV file, but the perfectionist in me insisted on an XML format. A preliminary test showed me, that I would be able to transform the XML to a CSV later on, so that my S.O. would be able to use it in his own programs.1
Having set up my development environment in MonoDevelop, I started to work on the problem on how to get my data into a well-formed XML representation and onto the hard disk.
The first approach was to use serialisation. I created a Location class, with all the necessary attributes – until I realised that this would only allow me to get one dataset into a file. I wouldn't be able to add more data to the file.
Conclusion: Serialisation is only good when you have one clearly defined object you want to dump onto the drive as a well-formed XML file.
So I tried to work with the XMLWriter.
-
So why again am I doing it with XML? Good question. Because I can? Does that make me a nerd? ↩
