- Home /
I can't load all text files from resources
Hello, I am trying to load all text files in my resources, into an array. I figured out that, I have to load them into a TextAsset Array. when I use this code to load one Text into a TextAsset variable It works perfectly:
TextAsset textFile = Resources.Load<TextAsset>("patterns/pattern1");
But when I try to load multiple into an array, it doesn't work. I don't get an error, just none of the files get loaded and the array stays empty. :
public TextAsset[] textFile;
textFile = Resources.LoadAll("patterns")as TextAsset[];
I have tried all of the methods listed in this thread: https://answers.unity.com/questions/1001509/how-to-correctly-load-all-assets-using-resourceslo.html but none of them have worked. I hope someone can help me out and thanks in advance.
Answer by SirPaddow · Jul 28, 2019 at 05:58 PM
This should work:
TextAsset[] textFile = Resources.LoadAll<TextAsset>("patterns");
Not sure why your solution does not work nor throws an exception tho... I would have expected an error, as you cast Object[] to TextAsset[]...
Your answer
Follow this Question
Related Questions
Check when text is done being printed? 1 Answer
Text not loading error 1 Answer
How to add text to Objects 1 Answer
How do you show a text when you are nearby an object? 1 Answer
Breaking text line in GUI.Box 1 Answer