Reading XML files outside of the Assets

Hello.
I’m trying to make a game in which I can save or read replays in XML files.
So I created a function to serialize and unserialize a replay in a file.

I created my Replays/ folder into the root of my projet, and all went well to read or write the files with the Unity Editor.

But then… I tried to build and run my project, and my files cannot be found anymore.
Where can I set my Replays/ folder to use it with a built project ? If that is not the problem, what should I do to read my files ?
Thanks.

You can use the streamingassets folder for loading data.

and Application.persistentDataPath for saving data

Even using the persistent data path with my files in the localLow or whatever, my files aren’t found by my built project. And the stremingassets don’t help. I don’t really understand… Is it only possible to load XML files from a built project ?

StreamingAssets worked like a charm for me. If one is to use this approach, make sure you’re using Application.streamingAssetsPath when you’re fetching the xml filepath, and have your XML files be in such folder StreamingAssets inside the project

Don’t use StreamingAssets for saving things. That directory is read-only in real life players.

1 Like