VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
void AVR.UEditor.Core.AVR_DevConsoleWindow.OnGUI ( )
inlineprivate

Definition at line 40 of file AVR_DevConsoleWindow.cs.

41  {
42  GUILayout.BeginVertical();
43 
44  //// SETTINGS BUTTON
45  GUIStyle sb = new GUIStyle(GUI.skin.button);
46  sb.font = AVR_EditorUtility.GetFont("/editor/fonts/font-awesome");
47  sb.fontSize = 11;
48 
49  string cog_symbol = AVR_EditorUtility.Unicode_to_String("f013");
50  if (GUILayout.Button(cog_symbol, sb, GUILayout.Width(25), GUILayout.Height(25)))
51  {
52  AVR_DevConsole.print("Settings Button doesnt do anything! :("); //TODO
53  }
54 
55 
56  //// OUTPUT TEXT AREA
57  // Output font style
58  GUIStyle s0 = new GUIStyle(GUI.skin.textArea);
59  s0.wordWrap = true;
60  s0.richText = true;
61  s0.alignment = TextAnchor.LowerLeft;
62  s0.fontSize = 16;
63  s0.font = AVR_EditorUtility.GetFont("/editor/fonts/inconsolata");
64 
65  // Output area color/bounds
66  GUI.contentColor = new Color(1f, 1f, 1f, 1f);
67  GUI.backgroundColor = new Color(0.288f, 0.296f, 0.319f, 1f);
68 
69  scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, true, GUILayout.Height(Screen.height - 85), GUILayout.Width(Screen.width - 10));
70  EditorGUILayout.TextArea(AVR_DevConsole.get_text(), s0, GUILayout.ExpandHeight(true));
71  EditorGUILayout.EndScrollView();
72 
73 
74  GUI.backgroundColor = new Color(0.088f, 0.096f, 0.019f, 1f);
75  GUI.SetNextControlName("InputField");
76  cmd_string = EditorGUILayout.TextField(cmd_string, s0, GUILayout.Height(20), GUILayout.Width(Screen.width - 10));
77 
78  if(Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Return) {
79  AVR_DevConsole.command(cmd_string);
80 
81  // This big "refocus" mess is here because for cmd_string="" to actually register, the textarea HAS to be out of focus for a coupla of frames.
82  // To accomplish this, we switch focus away with "GUIUtility.keyboardControl = 0", then 2 frames later (refocus>3) we focus back on the InputField with GUI.FocusControl("InputField")
83  // This way, the input-textarea actually clears when we run a command, but gets refocused so the user may input another command immediately aferwards.
84  cmd_string = "";
85  GUIUtility.keyboardControl = 0;
86  refocus = 1;
87  history = -1;
88 
90  Repaint();
91  }
92 
93  if (Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.UpArrow)
94  {
95  history += 1;
96  cmd_string = AVR.Core.AVR_DevConsole.history(history);
97  GUIUtility.keyboardControl = 0;
98  refocus = 1;
99  Repaint();
100  }
101 
102  if(refocus>0) {
103  refocus++;
104  if(refocus>3) {
105  GUI.FocusControl("InputField");
106  refocus = 0;
107  }
108  }
109 
110  GUILayout.EndVertical();
111  }