Opening up an XML file

At the moment, my game can open up an XML file inside the editor when I run it. In my XMLReader.cs I’m loading in my file like so:

_xmlDocument.Load(Application.dataPath + "\\HV_Settings\\Settings.xml");

However, when I build the game and run the exe, this file isn’t called. I know that I can store this file in the C drive, but I want to keep everything in one place so when I start to release what I’m working on, the user doesn’t need to do anything.

Am I doing something silly which is causing the XML not to be read?

Why don’t you use a ScriptableObject ?
They are intented to store data as an assets. You will use unity’s way to manipulate data (it will be easier).

To then load it at run time, either use a reference in one of your MonoBehaviour in your scene or use the Resources class to load it.

NB : it is better to use a reference because Unity will be able to optimize your scene at build time.

Instead of using an xml file, you will have to manipulate an asset file.

I’m creating the XML from an external app I’m also creating mate.

You can use the XmlTextReader from C# libs to read your file, or you can create a C# class and deserialize the class with XmlSerializer.

Found a fix:

I need to simply drag my XML file into the Resources folder found within the Game_Data folder Unity makes when you build your game.

Stupid and simple. But it works.