Is is possible to include XML files in a build?

I have a few XML files I want to include in a build of my game, and I want to have access to those XML files. Where can I put those XML files in order to have them be included in builds, and what will be the path to those XML files on each different platform?

Have a look:

I can’t figure out how to get an XML file to work from the resources folder.

My XML loader relies on loading a file by direct path… Is there a way to get the file path to the resources folder?

No, the resource folder does not exist in the build.
you need to make your xml loader capable of accepting a string, then you can load it as TextAsset

Ok, thank you.

For anyone seeking a solution this, here is what I did

using System.IO;

public TextAsset XMLObject;
StringReader xml;
Data data = new Data();

void Start(){

		xml= new StringReader(XMLObject.text);
		data = data .Load( xml);	

}

and my load function is this:

	public Data Load(StringReader xml)

	{

		var serializer = new XmlSerializer(typeof(Data));

		return serializer.Deserialize(xml) as Data;

	}

then you just drag you xml file onto the public textAsset in the inspector

1 Like

I know this is old, but I just encountered this problem myself. On Mac OS X you do not have to adjust your code, you can simply right click the .app → Show package contents → Resources and paste your XML folder.

Thank u, you solve my problem.