Im working on something that may have alot of txt files. I have to parse the information of each txt file and display them. I’m curious if there is a way to code(C#) in a script to attach a txt file automatically without me manually attaching it to one gameobject.
You could load a text file based on the object name.
Something like:
string fileName = this.name + "_text"; //--so if the name was object1, it would set the fileName to 'object1_text'
TextAsset textAsset = Resources.Load(fileName) as TextAsset;
string theText = textAsset.text;
Does the file have to be in a certain place in my project folder?
It should be in a folder called ‘Resources’.
can i have other folders in that folder and still have it called with Resource.Load
Yes, but you’d have to specify the path.
string folderName = "folder1/";
And load folderName + fileName.
Alright, thank you very much