TextArea Not Editable (C#)

Hi, so I looked this problem up, and it seems that everyone has forgotten the “text =” before the TextArea part. However, I do have it. Does anyone know why I can’t edit the text?

public Rect windowRect = new Rect(Screen.width / 2 - Screen.width / 4 , Screen.height / 2 - Screen.height / 4, Screen.width / 2, Screen.height / 2);
	
	 void OnGUI()
	{
		
		windowRect = GUI.Window (0, windowRect, windowFunc, "Text Editor: Extreme");
	}
	
	private void windowFunc(int id)
	{
		 string text = "Enter Text Here!";

		text = GUILayout.TextArea(text, GUILayout.Width(windowRect.width), GUILayout.Height(windowRect.height - 100));
		
		GUILayout.BeginHorizontal();

Your are resetting the local variable “text” every frame. Make text a global variable for the script(i.e. declared outside of the function) and your problem should be fixed

FYI to anyone having the same issue.

I had a similar issue where TextArea wasn’t accepting any of my edits (I did have a blinking cursor, and it was responding to arrow keys). As it turned out I was just assigning an initial constant value to the TextArea method, instead of a variable.

text = GUILayout.TextArea(AnotherClass.SomeConstantString, 10);

Once I changed to the following, it worked just fine.

text = GUILayout.TextArea(text, 10);