I’m making a word game, all words are stored in a SORTED txt file in my resources folder. I’ve learned the only way to be platform independent is to use the resources.load method. However, when I split my text asset into an array I am having trouble searching the array. Here’s my code`
TextAsset asset = (TextAsset)Resources.Load("words");
string[] words = asset.text.Split('
')`
Now if I print out random positions in the array the words print out as expected, so they are all properly loaded up. There are no extra characters. But for some reason when I do a binary search on it it never finds my word.
int result = Array.BinarySearch(words, "hello");
This will return a negative value indicating it couldn’t be found, even if I print out the exact location that I know where it is in the array and it prints out “hello”. To my eye they always look identical and this is driving me nuts. Could it have something to do with text encoding? It was working no problem when I did some file IO and split the file like `
string[] words = System.IO.File.ReadAllLines("Path");`
But if I do that I have to figure out the file path for each platform(this is mobile iOS, Android, shortly Windows phone).
I’m at a loss here…any help would be appreciated or other ideas. Thanks!
Steve