- Home /
Include Asset Directory in iPhone game
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?
Answer by MorphVGX · Jul 18, 2011 at 08:10 PM
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 .
Your answer
![](https://koobas.hobune.stream/wayback/20220612150226im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Does UNity iPHOne work 1.7 work with the new iPhone 4 os? 1 Answer
Make objects easier to select 1 Answer
Linking Native toolkit 1 Answer
I want to have FPS iOS tutorials. 0 Answers