- Home /
How do I include example resources in my iPad build?
I have a project which creates and manipulates png images. I wish to include several example images which have been already created. I want to place them in the app's document folder where I place all the user generated files. They are png images with extra metadata, as such I cannot include them as texture assets as their format will be converted. Is there a way to do this in Unity or do I have to include them in the XCode build process somehow?
Answer by TaintedLemon · Jul 27, 2011 at 02:08 AM
In XCode add the files you want to be included to the project.
Under the project settings "Build phases" check that "Copy Bundle Resources" includes the files you wish to include in your application bundle.
The first time application starts you can copy the files over. This can be done in your Unity code. The resource files are located at:
string sourcePath = Application.dataPath + "/../";
and you want to copy them into the documents folder which is at:
// Strip "/Data" from savePath
string documentsPath = Application.dataPath.Substring (0, Application.dataPath.Length - 5);
// Strip application name
documentsPath = path.Substring (0, path.LastIndexOf ('/'));
documentsPath += "/Documents";
You can copy the file using
File.Copy(sourcePath + "/TestFile.png", documentsPath + "/TestFile.png");
I'm not sure if there is a way to automate the including of files into the "Copy Bundle Resources" build phase.