How to load a textAsset from a txt in the resources folder

Hi! trying to load a txt into a textasset with the resource load (added my image getter just for reference and reading). For the images it works fine but the txt part… its only 1 .txt in a folder. Tried like it is now and also with “/text/”+print2+“.txt” … (print2 is the name of the file.

any clues? it just gives error, having a direct path to the file or only having to the folder…

Thxs :slight_smile:

(sry for the ugliness of the posted code, still not sure how to make it pretty :P)

GameObject print1 = GameObject.Find("variables"); string print2 = print1.GetComponent<SaveVariables>().name; print ("print: "+ print2);

foreach(Texture2D g in Resources.LoadAll("contos/"+ print2 +"/images", typeof(Texture2D))){ Debug.Log("aaaa: " + g); TextList.Add(g); }

TextAsset pathTxt = (TextAsset)Resources.Load("contos/"+ print2+"/text/", typeof(TextAsset)); if(pathTxt != null){ Debug.Log ("ok!"); }else{ Debug.Log("error"); }

I think it’s the path part that’s screwy, you need to specify the path starting at resources without the extension. So if your file is called print2 I think you want

TextAsset pathTxt = (TextAsset)Resources.Load("contos/"+ print2+"/text/print2", typeof(TextAsset));