- Home /
onclick save in xml
Hi :) I need your help please, because, i have a button, "save" and if the user clicks on this button, it should save the scene in an xml data,…. how can i do this? or is it possible?
xoxo Tina
Hi everyone!
Is it posible to make scenes using X$$anonymous$$L?
what i mean is Create buttons using xml and read X$$anonymous$$L in runtime to make that Button and display in scene.. and so on..
Answer by flamy · Jan 05, 2012 at 05:56 AM
It is completely possible in unity and there are various way to do it!!
if ur game is for Standalone, no much trouble implementing it, you can just use xmlTextwriter and xmlTextReader functions from system.xml namespace .After this you just have to call the functions of this class...
If it is not for standalone and ur platform doesnt support using dll, you have to write your own xml reader and writer according to ur neeed in this case you can use streamReader and streamWriter to save and retrieve data.
If your level data is not much ( may be 50 or so variables) you can check the playerPrefs to save them it would be straight forward approach..
The xmltextwriter and xmltextreader classes are stream based, which is preferable if the file is large (>1mb), because you can stream the data a little bit at a time over several frames, (or in a separate thread) so you won't obstruct the rendering. But if the file is small, you don't need to stream it asynchronously. You can construct the entire file with System.Xml.XmlDocument, and call XmlDocument.Save(string path) to save the file to disk. This is synchronous - it blocks until the saving completes. But XmlDocument is easier to work with in code when you build the X$$anonymous$$L.
ya i agree with christian but i wont be preferring to use the xml unless the data is too complicated because the X$$anonymous$$L is not all that fast to begin with and unity provides playerPrefs, which is good for a limited amount of data!
but i wont deny what you have said, it is true.
thank you all, great information :D thank you thank youuu <3, buuuuuuuuut, im a complete newbie in c# and unity and do you have any hints for program$$anonymous$$g it?
thank you soo much tinaa
okay, new problem, its not saving the scene in an xml, …. i'm working on 5 drop down fields, where you can choose from 6 choices each.
And i have to save now, with an save button, those choices who were picked in the drop downs, in an xml,…… so its only text,……..!
complicated,… how can i do this????
xoxo Tinaa
Hi everyone!
Is it posible to make scenes using X$$anonymous$$L?
what i mean is Create buttons using xml and read X$$anonymous$$L in runtime to make that Button and display in scene.. and so on..
Answer by $$anonymous$$ · Jan 26, 2012 at 06:47 PM
I think in the blog unitynoobs have a sample that you need http://unitynoobs.blogspot.com/2011/04/xml-writing-to-existing-xml-file.html
Your answer
Follow this Question
Related Questions
Saving/Loading Vertices Efficiently 2 Answers
My Function is not showing up in the OnClick Menu 2 Answers
UI Button not working 2 Answers
Random.Range 0 Answers
Putting a delay in a button OnClick ? (Javascript) 3 Answers