void DrawConsole(int Window2D) {
GUILayout.BeginVertical();
scroll_position = GUILayout.BeginScrollView(scroll_position, false, false, GUIStyle.none, GUIStyle.none);
GUILayout.FlexibleSpace();
DrawLogs();
GUILayout.EndScrollView();
if (move_cursor) {
CursorToEnd();
move_cursor = false;
}
if(Event.current.Equals(Event.KeyboardEvent("escape")))
{
SetState(ConsoleState.Close);
}
else if(Event.current.Equals(Event.KeyboardEvent("return")))
{
EnterCommand();
}
else if(Event.current.Equals(Event.KeyboardEvent("up")))
{
command_text = History.Previous();
move_cursor = true;
}
else if(Event.current.Equals(Event.KeyboardEvent("down")))
{
command_text = History.Next();
}
else if(Event.current.Equals(Event.KeyboardEvent(ToggleHotkey)))
{
ToggleState(ConsoleState.OpenSmall);
}
else if(Event.current.Equals(Event.KeyboardEvent(ToggleFullHotkey)))
{
ToggleState(ConsoleState.OpenFull);
}
else if(Event.current.Equals(Event.KeyboardEvent("tab")))
{
CompleteCommand();
move_cursor = true; // Wait till next draw call
}
GUILayout.BeginHorizontal();
if (InputCaret != "") {
GUILayout.Label(InputCaret, input_style, GUILayout.Width(ConsoleFont.fontSize));
}
GUI.SetNextControlName("command_text_field");
command_text = GUILayout.TextField(command_text, input_style);
if (input_fix && command_text.Length > 0) {
command_text = cached_command_text; // Otherwise the TextField picks up the ToggleHotkey character event
input_fix = false; // Prevents checking string Length every draw call
}
if (initial_open) {
GUI.FocusControl("command_text_field");
initial_open = false;
}
if (ShowGUIButtons && GUILayout.Button("| run", input_style, GUILayout.Width(Screen.width / 10))) {
EnterCommand();
}
GUILayout.EndHorizontal();
GUILayout.EndVertical();
}