- Home /
XML File not reading in Mac OSX build
Hi, I've got an XML file which holds objective information which is breaking the game if it fails to load correctly. The xml file is placed within the streaming assets folder and is accessed by:
string filePath = Application.dataPath + "/StreamingAssets/ObjectiveData";
using (XmlTextReader xr = new XmlTextReader(filePath + ".xml"))
{
//code
}
This problem only happens when running an executable build on Mac OSX. This works fine on Windows Build, and in the editor on both Windows and Mac. How can I get the Mac OSX build to read from this XML file?
Hi, I got this problem too. Is the problem have solved yet? I'm some kind of new to Unity, and I use FileS$$anonymous$$m to accessed xml, but seems it doesn't work when build on $$anonymous$$ac OSX, but it works perfectly on unity editor. If you have solved this problem, may you give some advice?
Here is my code:
private static Container Load(string path)
{
XmlSerializer serializer = new XmlSerializer (typeof(Container));
FileStream stream = new FileStream (path, File$$anonymous$$ode.Open);
Container con = serializer.Deserialize (stream) as Container;
stream.Close ();
return con;
}
private static void Save(string path, Container cards)
{
XmlSerializer serializer = new XmlSerializer (typeof(Container));
FileStream stream = new FileStream (path, File$$anonymous$$ode.Truncate);
serializer.Serialize (stream, cards);
stream.Close ();
}
Your answer
Follow this Question
Related Questions
In-app purchase "Invalid product" on Mac Store build 0 Answers
A node in a childnode? 1 Answer
assign file type to a game? 1 Answer
XmlException: Root element is missing when deserializing 2 Answers