Answer the question
In order to leave comments, you need to log in
How to work with files in StreamingAssets?
The Unity project is implemented for android. I put the files in the StreamingAssets folder in the Assets folder. I write the path to the file:
fileName = "jar:file://" + Application.dataPath + "!/assets/" + "questions.txt"
public void ReadFile (string filename, int numberQuestion) {
using (StreamReader reader = File.OpenText(filename))
{
string line = null;
for (int i = 0; i <= numberQuestion; i++) {
line = reader.ReadLine();
questionText.GetComponent<Text>().text = line;
}
}
}
Answer the question
In order to leave comments, you need to log in
And in general, text data can be accessed in resources as TextAsset
well as not having trouble with files.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question