I have a system where i write out a text document in notepad, and i can put it in unity, and then use it as dialogue for my game. how would i do it, if i wanted to change out the file, for another, ingame?
string szFilename = “Lucas.txt”; //place Lucas.txt in
// C:\Users*your_user*\AppData\LocalLow*your_company**your_game* on Windows
string szFilenameNoExt = “Lucas”; //place Lucas.txt in project_path/Assets/Resources/Dialog/
string szDialogPath = “Dialog/”;
//for a static file (at compile time)
TextAsset f = (TextAsset)Resources.Load(szDialogPath + szFilenameNoExt);
string szFileText = System.Text.Encoding.UTF8.GetString(f.bytes);
//for dynamic file (changeable when ever)
string szFileText = System.Text.Encoding.UTF8.GetString(
File.ReadAllBytes(Application.persistentDataPath + "/" + szFilename));
szFileText will now contain the contents of Lucas.txt