I know there is already a lot of topics about that, but none of them really helped me.
I store Scores into an xml file as below
[System.Serializable]
public class oneScore
{
public int score;
public string name;
public string email;
public oneScore()
{
score = 0;
name = "unnammed";
email = "noEmail";
}
}
[System.Serializable]
public class AllScores
{
[XmlArray("Score")]
public List<oneScore> list = new List<oneScore>(500);
}
public void LoadScore()
{
XmlSerializer serializer = new XmlSerializer(typeof(AllScores));
FileStream stream = new FileStream(Application.dataPath + "/StreamingAssets/Scores.xml", FileMode.Open);
scores = serializer.Deserialize(stream) as AllScores;
stream.Close();
}
Everything’s working perfectly fine in the editor, Scores are loaded at start, new ones are well added, etc
But when I build the project on Windows, loading an already existing Scores.xml just doesn’t work.
If there is not Scores.xml, my script is able to create a new one and then save and load it fine, even if i restart the game, at the exact same path…
I really don’t understand why I can’t load an already existing xml file. I’m storing Scores.xml in StreamingAssets btw, so it is not compressed or anything.
Oh, great, did u noticed that encodage had changed ?
So i still dont know how to encode in utf-8 from editor, but if you want to store data from editor into an xml file, and then use this xml file in build, u have to make sure it is encoded as “utf-8” and not “Windows-bullshit” manually.
EDIT : Or, u can add missing dll to support “Windows-bullshit” into your asset folder