- Home /
Build settings: how to export files into the build
Hi, I'm building my game for PC platform. In my Assets folder I've put some files and folders, for example there's an xml with some setting parameters of the game.
I get the files in my scripts using the Path (for example "Assets\\Settings\\settings.xml")
The game is working great in the unity editor, but when I start the built .exe version, it shows me the error that it cannot find those files in the Assets folder.
So which is the best way in order to use some custom files that is available also in the Built version?
Thank you!! :D
hi you do know that unity uses scens to build your game ie when you click build you should add scenes that you would like to use in your game go here to know what i am saying
/PublishingBuilds.html
and why are you using xml files for(by setting did you mean your game setting or other unity setting if) try putting them in standard asset folder
Hi, thanks for your reply.
Yes i've added all the scenes in the Build Settings.
I'm using some extra xml files for some settings of my game and for example each level of the game is described by an xml file in the folder Assets/Levels...
So it's like the built version is not able to reach the Assets folder...
Answer by flamy · Mar 15, 2013 at 09:34 AM
The assets that are used in the scenes that are included in the build settings are only exported during the building process. So custom files like XML or TXT are not included normally......... Unless it is inside "Resources" Folder.
So Make a folder named Resources in side assets folder and place your xml inside that
And now loading the XML is a bit tricky,
TextAsset temp = Resources.Load(XmlFileName) as TextAsset;
XmlDocument _doc = new XmlDocument();
_doc.LoadXml(temp.text);
instead of loading from stream or other you have to use TextAsset from unity to load xml here. except the loading part the method of handling would be the same ..
Hope it helps :)
happy tht it works :). FYI all custom files should only be handled this way, whether it is xml or txt or watever format it is.
Since I need also to update this files, and this should work on all platform devices, the Resources folder is not good.
The final solution is to add all the content in the Strea$$anonymous$$gAssets folder, and copy all of that content into to PersistentDataPath for example during the first Scene.
Thanks.
@catwoman - Could you please explain how can I do that with an example. I am having a xml file with question and choices in the game, which needs to be updated. Its a standalone build for PC & OSX, have placed the file in strea$$anonymous$$g assets folder and assigned in the game directly. Found it in the build, its not updating in the game when I made changes in that file.
Regards, Ben
this comment helped me a lot
more on the Strea$$anonymous$$gAssets folder here : https://docs.unity3d.com/$$anonymous$$anual/Strea$$anonymous$$gAssets.html
not understood.. it will be helpful if you give some code example of updating xml document...
Your answer
![](https://koobas.hobune.stream/wayback/20220613094446im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How can I stop the variable values reverting to its default values after being built? 1 Answer
Create / preserve file in asset folder. 2 Answers
I built my project for WebGL but no files were created in the target folder. 0 Answers
Unity freezes on Packaging assest:sharedassets0.assest 2 Answers
Why i cant see anything? ANYTHING! 1 Answer