- Home /
Save/Load game using XML on Browser/Web Player
I am currently working on the ways to store the location and tags of the game objects online and trying to load them dynamically on calling them. I looked into this XML wiki - http://unifycommunity.com/wiki/index.php?title=Save_and_Load_from_XML and am using the JavaScript included there. The script works properly when I run it in the editor and also as a stand alone app. But it doesn't work on the browser. Should I rewrite the script to actually use WWW to load the xml file or am I doing something wrong? Am currently using the script with its File IO The Application.dataPath for some reason does not work with the web browser.
Answer by diabloroxx · Aug 02, 2010 at 04:06 PM
For all other new users who want to know what I did to use XML on web player-
I loaded the XML file using the WWW class to load the URL.
function LoadXML()
{
var url = "http://localhost/unity/sample.xml";
var www = new WWW(url);
while(!www.isDone)
{
yield WaitForSeconds(1);
}
yield www;
var _info : String = www.data;
_data=_info;
}
For writing back to the XML, I had to write a PHP file and called it using the WWWForm.
when i try this code on my unity window works fine but when i build the same code it just hang up the browser is three any way i can solve that problem
Answer by Eric5h5 · Jul 19, 2010 at 07:39 PM
You can't use local file I/O in the web player for security reasons.
Yeah. I figured that out. Are there any other methods to do this on the web player without using too much resource? All that I need to do is, get number of objects and the tags with location to display them on the screen. The user can modify location on screen though.
Your answer
Follow this Question
Related Questions
Saving Game Problem 1 Answer
Load XML File ? 1 Answer
Xml Saving and Loading Problems 1 Answer