Greetings unity community,
I have a chat field that is represented by a GUI.Window and a TextField at the bottom of that window.
function OnGUI() {
window = GUI.Window(1, window, GlobalChatWindow, "Chat");
}
function GlobalChatWindow(id : int) {
/*here be actual chat window logic etc, not really important as it works*/
//sets the control name
GUI.SetNextControlName("chatField");
//creates an actual field
inputField = GUILayout.TextField(inputField);
//getting focus when pressing the 'T' button
if (Input.GetKeyDown(KeyCode.T)) {
GUI.FocusControl ("chatField");
}
}
The problem hereby is, that the inputField takes on the ‘t’ string and I can’t seem to delete that t as the logic records it when I’m out of the if logic already.
Say the TextField is unfocused and I’m running around ingame.
Then I press ‘T’.
The field gets focused but with the content ‘t’ which I have to delete manually afterwards.
How do I get rid of this? inputField = “”; either doesn’t work at all (when inside the if logic) or too good and blocks all chatting when outside the if logic.
Greetings, Cirrus