Here’s what I have so far…
var naming1 : boolean = false;
var slot1_namer : GUI;
var slot1_name : String;
function Update (){
if(Input.GetKeyDown(Keycode.Return))
{
if(naming1 == true)
{
naming1 = false;
}
else if(naming1 == false)
{
naming1 = true;
}
}
}
function OnGUI (){
if(naming1 == true)
{
slot1_namer.enabled = true;
slot1_name = slot1_namer.TextField(new Rect(0,0,100,25),slot1_name,25);
if(Input.GetKeyDown(Keycode.Return))
{
slot1_namer.enabled = false;
slot1_name = slot1_namer.TextField(new Rect(0,0,100,25),slot1_name,25);
}
}
else if(naming1 == false)
{
slot1_namer.enabled = false;
slot1_name = slot1_namer.TextField(new Rect(0,0,100,25),slot1_name,25);
}
}
redundant in the end, I know, but I was REALLY trying to get this to work. So how can I disable (or ideally “hide”) the textfield when “return” or “enter” is pressed?
EDIT: New development, every time I leave then go back to the menu with the TextFields, the ability for “enter” to enable and disable them is reset. Meaning that as long as none of the fields are edited, the code works properly and they fields enable and disable. yet if any of them are edited, this stops working so I have to back out then go back in.