In Game Notepad

Hi Guys, I am thinking on adding an In-Game-Notepad.
I have written a basic starter script

    var stringToEdit : String = "Notes:";

function OnGUI () {
   if (Input.GetKeyDown ("n"))
    stringToEdit = GUI.TextArea (Rect (400, 400, 200, 100), stringToEdit, 200);
}

I wan’t the player to be able to press “n” and a window opens up where he can write down stuff e.g Memos,reminders etc.

But I can’t get the window to show up?

Thank you in advance! -Izzy

When using OnGUI(), the gui has to be rendered every frame. So, if you have it render when you press a button, it will only render for a very slight amount of time. I think something like this will help:

var stringToEdit : String = "Notes:";
var menuOpen : boolean = false;
 
function OnGUI () {
   if (Input.GetKeyDown ("n")) {
      menuOpen =! menuOpen;
   }
   if (menuOpen) {
      stringToEdit = GUI.TextArea (Rect (400, 400, 200, 100), stringToEdit, 200);
   }
}

Sorry if my syntax is incorrect, I am used to C#.

If it’s a notepad, that would mean that you want a player to be able to actually save information on it, right? Should the notepad info get saved when you leave a game and come back?