- Home /
Using XML for a simple webplayer Highscore Table
Hi, i've been searching around the interweb for days now trying to figure out XML read/write routines. I've made a simple Pinball Game and exported it as a webplayer application, but i need a Highscore Table. At first i thought a database would be the best approach. But for some reason ever since i heard of databases a few years ago, everytime i try to understand databases my brain shuts down. So Saving/loading the scores from a read/write file seems better for me.
i'm thinking my XML would look something like:
<1stName>RandomName1</1stName>
<1stScore>123</1stScore>
<2ndName>RandomName2</2ndName>
<2ndScore>213</2ndScore>
... and so forth...
now to my question: how do i get the values from the different XML elements assinged to variables and how do i overwrite the old values with the updated variables i get from playing?
it seems rather easy but for some reason i cant wrap my brain around it.
Thanks in advance! :)
EDIT: I use UnityScript (JavaScript) By The Way
Why do you need to save in xml format? Why not just save the data line by line. Or use playerprefs. If you have to use xml, use google, and search for "unity xml" and I guarantee you'll find thousands of hits.
How do I save the data line by line and in what format then? And what is playerprefs? And how do I use that? X$$anonymous$$L just seemed like the only real way for me to go. I used the exact search terms "unity xml" and yes I found 2-3 hits although in these tutorials they do all sorts checks and advanced routines which covers up the point for me. If there is an easier way, I would definitely use that way. Because the biggest part of my game will nnot be highscore depending.
Well i tried PlayerPrefs which seemed to work fine, until i deployed my game and found that, as the name states, PlayerPrefs are player specific. which means people still cant compete for highscore. That leaves me with two choices line-by-line in a text file or X$$anonymous$$L as i first stated.
Answer by Graham-Dunnett · Apr 14, 2013 at 01:38 PM
Visit Google
Enter "unity write text file"
Press search button.
Click first hit (or visit http://answers.unity3d.com/questions/23578/how-do-i-write-a-line-of-text-to-a-file.html directly.)
But this only solves half the problem, it allows me to write to text file but not to read and convert data to variables from textfile... I've since found that for my purposes Read/Write of a textfile wouldn't have worked anyways... but thanks for trying atleast :)
Your answer
Follow this Question
Related Questions
Work with XML hidden for the user? 1 Answer
Write and Read to a iOS device! Help 1 Answer
Saving My World 1 Answer
How to make/write to files, then read immediately? 1 Answer
XmlException when trying to read/write XML from iOS device 1 Answer