- Home /
How to create a gui that the user can write in and save?
Hi I want to create a simple gui that allows the user to write in side the gui like a notepad kind of thing, but I it doesn't have to open a new gui space to write in everytime the user runs the program, what the user wrote last time in the gui I still want to be there. but I just want them to be able to edit the last thing the user wrote and then save it, so when the user opens it again it what the user wrote will still be there. Thanks and i'm kind of new to programming so please go easy on me, thanks so much.
Answer by TheDarkVoid · Dec 10, 2012 at 05:52 PM
Here is a simple script for that:
using UnityEngine;
using System.Collections;
public class SumRandom : MonoBehaviour {
public string InputText;
public int MaxLenght = 100000;
void OnGUI()
{
InputText = GUI.TextField(new Rect(5,5, 500, 250), InputText, MaxLenght);
if(GUI.Button(new Rect(5, 260, 245, 20), "Save"))
{
PlayerPrefs.SetString("SavedInput", InputText);
}
if(GUI.Button(new Rect(260, 260, 245, 20), "Load"))
{
InputText = PlayerPrefs.GetString("SavedInput");
}
}
}
If you or someone could give me a example code or how you would do it, i'm not very code savvy if you don't have time thats ok, thanks for the help so far:)
Thanks it worked, but for some reason I can't click enter to make it so the words will be able to go under the text example below of what it won't let me do, is there anyway to fix that?
$$anonymous$$y Schedule: Create Unity3d project Go to church Go grocery shopping
Not sure what you're asking, are you trying to make a new line by pressing enter?
Your answer
Follow this Question
Related Questions
How to create a gui button inside an if statement? 1 Answer
Inputing an Equation 0 Answers
Simple Backpack "Pick up and drop" 1 Answer
My own GuiSkin on the script 2 Answers
GUI button not showing up 1 Answer