- Home /
GUI Text Area that Reads / Writes / Saves
I am having the hardest time trying to get this done.
I have a Text file that is blank, That i want to Read / Write too. however, I want the GUI to be able to read it in a Text area, and Edit the Text file in realtime, or a button that would save the changes to a Text file.
Any known way of doing this?
Answer by Statement · Mar 27, 2011 at 01:27 PM
If you're in standalone player:
import System.IO;
var contents : String = "Write some text!"; var file : String = "somefile.txt";
function Start() { Load(); }
function OnGUI() { // Use contents string in text area. // Have buttons call load and save. }
function Load() { contents = File.ReadAllText(file); }
function Save() { File.WriteAllText(file, contents); }
This waas exactly what i was looking for - I appreciate it greatly!
Answer by Justin Warner · Mar 27, 2011 at 12:04 PM
http://answers.unity3d.com/questions/4052/read-and-write-to-text-file-online
Eric's answer and follow up comment should help you begin.
Your answer
Follow this Question
Related Questions
My text document is updating twice when its only supposed to once 2 Answers
How do you get Unity to return a user input? 1 Answer
Text Prompt Problem 1 Answer
guiText.HitTest(Input.mousePosition) is not triggering 0 Answers
GUI text Main Menu 1 Answer