I have a directory with text files that I need to read and store as game data. Using:
private void loadTextFiles()
{
DirectoryInfo directoryInfo = new DirectoryInfo(Application.dataPath + "/" + myPath);
FileInfo[] filesInfos = directoryInfo.GetFiles("*.txt");
foreach(FileInfo fileInfo in filesInfos)
{
//Here I read each file
}
}
I can make it work like this in the editor, but the directory is not found in my iPhone. How can I achieve this?
Thank you. So what I understand is that I may be able to place a directory inside the iPhone but that would be manually or by using a post build script. But if I do that, those files won’t be encrypted and that is not feasible, because this is level data that a player could modify to cheat. I could use some encryption on my own but I don’t have the time for a solution like that.
Then, as I cannot use a directory to get files from there, what I think I can do is have a persistent xml file (within a txt file as I’ve read xml as TextAssets won’t work in iPhone) where I add the name of every level by code and then I use that to load every file by name using Resources.Load .