- Home /
 
               Question by 
               jaydenhall125 · May 12, 2020 at 02:38 PM · 
                c#2dtextdialogue  
              
 
              How to change a notepad file for another notepad file?
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?
 
                 
                capture.png 
                (69.9 kB) 
               
 
              
               Comment
              
 
               
              Answer by rh_galaxy · May 12, 2020 at 03:32 PM
 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
Your answer
 
 
             Follow this Question
Related Questions
Multiple NPCs 1 Answer
How to display UI Text on GameObject in script? 0 Answers
How do i make a BattleLog? 0 Answers
Trouble with Unity2d Text 0 Answers
Multiple Cars not working 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                