- Home /
Xml Saving and Loading Problems
In my game, I have added a remember function for my login/register thingy. The code is as follows: Here is my LoginInfo class for the XmlRoot
@XmlRoot("LoginInfo")
public class LoginInfo{
@XmlAttribute("username")
public var username : String = "";
@XmlAttribute("password")
public var password : String = "";
@XmlAttribute("rememeber")
public var remember : boolean = false;
}
And to use this I have a function called Save() and Load()
function Save(path : String){
var serializer : XmlSerializer = new XmlSerializer(LoginInfo);
var stream : Stream = new FileStream(path, FileMode.Create);
serializer.Serialize(stream, loginInfo);
stream.Close();
}
function Load(path : String) : LoginInfo{
var serializer : XmlSerializer = new XmlSerializer(LoginInfo);
var stream : Stream = new FileStream(path, FileMode.Open);
var result : LoginInfo = serializer.Deserialize(stream) as LoginInfo;
stream.Close();
return result;
}
This works perfectly for the editor game window thing, but when I play it with a build it does not seem to work. Also in the editor console, sometimes this line comes up:
ms_IDToPointer->find (obj->GetInstanceID ()) == ms_IDToPointer->end ()
Any help is appreciated, william9518
Answer by LouisSong · Sep 29, 2013 at 01:47 AM
it may be related to your target platform,You can use PlayerPrefs instead.
Sorry, but I have to use XmlSerializers in this case.
Your answer
Follow this Question
Related Questions
Save and load arrays into an XML file 1 Answer
Save and Load data from Local XML file won't work 1 Answer
SaveLoad Profile c# to xml 4 Answers
Save and Load from XML help 1 Answer
Loading Xml file issues 0 Answers