Hi,
I’m trying to load XML file into game,
I want to be able to switch XML files without building a project again with new preset.
(to be able to add new item into the XML)
Currently my xml loader works perfectly if I attach XML file to
public TextAsset _xmlFile;
meaning I should have XML file in project assets folder
meaning I won’t be able to modify my XML after building project.
when I build my game I would copy XML into it’s Data folder or Resources,
code should locate XML
(path/location is always the same eg. “Application.dataPath\Resources\itemList”)
and load it as TextAsset.
I’ve googled this problem and coudn’t find a solution or I misunderstood some.
I’ve tryied this one and many others:
// if your original XML file is located at
// "Resources/MyXMLFile.xml"
TextAsset textAsset = (TextAsset) Resources.Load("MyXMLFile");
XmlDocument xmldoc = new XmlDocument ();
xmldoc.LoadXml ( textAsset.text );
that would mean I need “TextAsset textAsset = (TextAsset) Resources.Load(“MyXMLFile”);”
So I built project with that code, copied my XML in resources folder inside game’s Data folder and it’s not working. Every solution that can be found on google is same as that one or like “make a public variable and attach your xml to it”