Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

How do I load my txt file in iOS

$
0
0
Hello! Ok, I'm pretty noobish so here we go. I've been at this for hours now, researching and testing but to no avail. I've got this working just fine in the editor, but when I build to my iPhone, it builds fine, but the text won't load. I'm guessing it's because it can't find the .txt file once it's built. I tried using resources.load, but frankly,I really can't figure this out. So, I have a giant word list named "wordlist.txt". All words are separated by line breaks. I'm just trying to load a word from the file and pass it to the textmesh on the iOS. Thanks! #pragma strict import System.IO; function Start () { var fileName = "wordlist.txt"; var sr = new StreamReader(Application.dataPath + "/" + fileName); var fileContents = sr.ReadToEnd(); sr.Close(); var mydata = fileContents.Split("\n"[0]); // pick a random number between 1 and 10 var myrandom = Random.Range(1,100000); GetComponent(TextMesh).text = mydata[myrandom]; }

Viewing all articles
Browse latest Browse all 4709

Trending Articles