This is the second time I’ve run into this issue now but the first time I had a simple workaround. This time I do not. I have a leveldata.xml file in my assets directory. I don’t write to it ever, but it contains the basic level information (name of the level, ID, the series it belongs to) and I read from it one time when the player starts. It works fine in the editor, but when I build to either PC or Android it suddenly can’t see the xml file. I’m starting to wonder if Unity doesn’t include the file in the build despite it being in the Assets folder? I don’t want to use persistentDataPath because we manually register our levels in this file and need it for version control. That’s why it’s in Assets (dataPath).
Any thoughts on this? Oh, and here’s my exception from logcat.
I/Unity (18641): IsolatedStorageException: Could not find a part of the path "/data/app/com.covalentgames.zoeyball-2/base.apk/Levels/leveldata.xml".
I/Unity (18641): at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x001f9] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/FileStream.cs:290
I/Unity (18641): at System.IO.FileStream..ctor (System.String path, FileMode mode, FileAccess access, FileShare share) [0x00000] in <filename unknown>:0
I/Unity (18641): at System.IO.File.OpenRead (System.String path) [0x00000] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/File.cs:363
I/Unity (18641): at System.IO.StreamReader..ctor (System.String path, System.Text.Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) [0x0005f] in /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.IO/StreamReader.cs:164I/Unity (18641): at System.IO.StreamReader..ctor (Sys
I’m not sure what to do. The file is in Assets/Levels/. I’ll paste my deserialize code too I guess. That’ll likely help. Though it works when ran from the editor perfectly.
public void DeSerialize(ref List<GameManager.Level> levelList) {
XmlSerializer serializer = new XmlSerializer(typeof(List<GameManager.Level>));
using (TextReader reader = new StreamReader(Application.dataPath + @"/Levels/leveldata.xml")) {
levelList = (List<GameManager.Level>)serializer.Deserialize(reader);
}
}