I need to load a text file from the resource folder that holds an objects properties. Im thinking that I need to use resources.load since the assets in the resource folder are protected upon compile, or else id just use a relative path on stream reader.
so can i use resources.load to find a text file and then pass that text file into stream reader?
Since the URLs of the accepted answer are now dead, I’ll leave here new links that I found trying to solve the problem.
You don’t have to use StreamReader when using TextAssets, and it is actually better because on webgl builds (and other particular cases), StreamReader won’t be able to find your files. Here is the TextAsset version to read every line of your file:
private List<string> TextAssetToList(TextAsset ta)
{
var listToReturn = new List<string>();
var arrayString = ta.text.Split('
');
foreach (var line in arrayString)
{
listToReturn.Add(line);
}
return listToReturn;
}