Hey,
I am using some TextAssets which simply contain a few words, one on each line.
I want to be able to load it into an list of strings.
I have implemented it, however, for on of these files it works perfect, for the other, it seems to just leave out some words without any real reason.
Here is the code I am using to load the TextAsset:
WordList selectedWordList = new WordList();
foreach (WordList list in gm.wordLists)
{
if(list.name == gm.selectedWordList.listName)
{
selectedWordList = list;
break;
}
}
string listText = selectedWordList.wordList.text;
if (listText.Length <= 0)
{
Debug.LogError("[Error] Could not find list or list contains no words");
return;
}
string[] wordList = listText.Split(new char[] { '\n', '\r' });
wordLists.availableWords = wordList.ToList();
here are the words within the file I am testing:
algebra
pythagoras
coordinates
division
vector
multiplication
And here is the result:
Here is another word file where it works perfectly:
Sublime Text:
Unity:
(Its a few less in Unity because some have been assigned to enemies already)