Hey guys. I'm having a problem with this Javascript. I want to have this line { (GUI.Box (Rect (10,10,100,90), stringToEdit); } that creates a GUI box inside of an if statement to create it when certain parameters are met. When I put it inside the if statement however, the GUI won't create. It will only create when I move it outside the if statement. Is there any way I can do this or something similar?
var stringToEdit : String = "Hello World";
function OnGUI () {
stringToEdit = GUI.TextField (Rect (100, 135, 200, 20), stringToEdit, 25);
GUI.Box (Rect (10,10,100,90), stringToEdit);
if (Event.current.type == EventType.KeyDown && Event.current.character == "\n"[0])
{
stringToEdit = "";
//GUI.Box (Rect (10,10,100,90), "stringToEdit");
Debug.Log("GUIBox");
}
}
↧