Hi,
i know you can save files to the DataPath/Documents path when you play the game.
But for my project i need the files to be there when installing the game. So is it somehow possible to add the files to that folder when creating the build?
I tried creating a folder into the xcode build output path but it gets overridden when compiling.
Thanks,
Kiyaku
Can you create the files in an object’s Awake function in the first scene?
I guess so, kinda, i was just talking with people on the irc and i guess i can save them as text assets, put the into resources, load them at gamestart and then save them to the documents folder. Will try that out 
Here is a simple javascript implementation of what Kiyaku suggested for a “description.txt” file that was imported into the Resources folder in the editor:
import System;
import System.IO;
function Awake () {
var docPath : String = Application.dataPath;
if (Application.isEditor) {
docPath += "/Resources/description.txt";
}
else {
docPath = docPath.Substring(0, docPath.Length - 5);
docPath = docPath.Substring(0, docPath.LastIndexOf("/"));
docPath += "/Documents/description.txt";
if (!IsFileExisting(docPath)) {
var myText : TextAsset = UnityEngine.Resources.Load("description",TextAsset);
WriteFile(docPath,myText.text);
}
}
ReadFile(docPath);
}
private function ReadFile(file : String)
{
if(IsFileExisting(file))
{
var readText : String = System.IO.File.ReadAllText(file);
Debug.Log( readText);
}
else
{
Debug.Log("Error opening: " + file + " for reading.");
return;
}
}
private function WriteFile (file : String, text : String){
if (IsFileExisting(file))
{
Debug.Log(file+" already exists.");
return;
}
System.IO.File.WriteAllText(file,text);
}
private function IsFileExisting(file : String) {
return File.Exists(file);
}
Well as far as i can tell, your code requires your “description.txt” to be in the /Documents folder already.
I wanted to have it pre-installed on the iDevice, that was my problem.
But i solved it by just adding it to a variable on component and then save it to the Documents folder on start:
/*
From Setup.cs:
iPhonePath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "Documents");
public TextAsset[] iPhoneDBFiles;
*/
if(!File.Exists(Setup.Ins.iPhonePath + "/itemDB.xml"))
{
foreach(TextAsset asset in Setup.Ins.iPhoneDBFiles)
{
TextWriter tw = new StreamWriter(Setup.Ins.iPhonePath + "/" + asset.name + ".xml");
tw.Write(asset.text);
tw.Close();
}
}