void OnGUI()
{
if (!display)
{
return;
}
// Display window
wnd = GUILayout.Window(-1, wnd, WndDisplay, "CrownEngine Console");
// Keyboard control
if (Event.current.type == EventType.KeyUp)
{
// On TextField focus
if (GUI.GetNameOfFocusedControl() == "TextField")
{
// Execute on Enter
if (Event.current.keyCode == KeyCode.Return && wndTextField != "")
{
Crown.Exec(wndTextField);
lastText.Add(wndTextField);
lastTextId = lastText.Count;
wndTextField = "";
}
// List input story on up and down arrows
if (lastText.Count > 0)
{
// Previues text on up arrow
if (Event.current.keyCode == KeyCode.UpArrow)
{
if (lastTextId > 0)
{
lastTextId--;
}
wndTextField = lastText[lastTextId] as string;
}
// Next text on down arrow
else if (Event.current.keyCode == KeyCode.DownArrow)
{
if (lastTextId < lastText.Count - 1)
{
lastTextId++;
wndTextField = lastText[lastTextId] as string;
}
else
{
wndTextField = "";
}
}
}
}
// Hide console on Escape button
if (Event.current.keyCode == KeyCode.Escape)
{
display = false;
}
}
}