How do I include a custom file in my build?

I have 6 save game files that are created using C# serialization. I need these files to be included in my build. With a PC version, I can simply copy/paste the needed files into the final build folder. Under Android, due to it packing everything into a *.apk file, I am unable to include the needed game save files. I tried placing them in the Assets/Resources/saves folder and even added a new JS file with the following code:

function Start(){
    Resources.LoadAll("saves");
}

But Unity is still not packing my save files into the build…

How can I tell Unity that these files are required and make them part of the build??

Try putting them into a file named Resources

Tried the "Resources" folder... still not working. I might resort to creating a 'gaveSaves.js' that is nothing but a list of every variable for each of the game saves... At least that way I know where my info is, how to access it, and am guaranteed it will be included... Downside is the amount of code re-writing...

Still seeking an answer to this one... Hoping this comment serves to "bump" my question...

3 Answers

3

I got them working under Android. The problem was resolved when I imported them in the Editor, instead of copying them into the directory.

-arsalank2

Sounds like Occam’s Razor!! The best answer is the most obvious… Thanks!!

hello, Im trying to do the same thing! its not working... how did u managed to add them using the import inside unity editor? I tried it.... its not adding my files to the built... please advise..

Heya,

I’m not developing for Android, so bear with me if this doesn’t help you, but I did a quick google to try and find a solution for you.

According to this question on how to save and read data on android, you can either use PlayerPrefs to store the variables that define a saved game, or if the data you need included is unsuitable for PlayerPrefs, you can store the files on the SD card and read/write using Application.persistentDataPath. I think that’s the way to do this - you don’t need the data embedded in the Unity build.

I have exactly same the question. Resources do not seem to work for Android. Does anybody has an answer?

I got them working under Android. The problem was resolved when I imported them in the Editor, instead of copying them into the directory.

"I got them working under Android" where should i open this "Android" folder?