Skip to content

Commit bd5b61c

Browse files
committed
Added Help Box to Commands
1 parent e397b79 commit bd5b61c

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

Assets/Scripts/Commands/CommandConsole.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using System.Collections.Generic;
44
using UnityEngine;
5+
using UnityEngine.UI;
56

67
public class CommandConsole : MonoBehaviour
78
{
@@ -175,7 +176,8 @@ void DefineCommands()
175176

176177
};
177178
}
178-
179+
180+
private Vector2 scroll;
179181
private void OnGUI()
180182
{
181183
if (!showConsole) { return; }
@@ -186,7 +188,28 @@ private void OnGUI()
186188
GUI.FocusControl(null);
187189
Event.current.Use();
188190
}
189-
float y = Screen.height - 45;
191+
192+
float y = 60;
193+
194+
if (showHelp)
195+
{
196+
197+
GUI.Box(new Rect(0,y,Screen.width,100), "");
198+
Rect viewport = new Rect(0, 0, Screen.width - 30, 20 * commandList.Count);
199+
scroll = GUI.BeginScrollView(new Rect(0, y + 5f, Screen.width, 90), scroll, viewport);
200+
201+
for (int i = 0; i < commandList.Count; i++)
202+
{
203+
UtilityCommandBase command = commandList[i] as UtilityCommandBase;
204+
string label = $"{command.commandFormat} - {command.commandDescription}";
205+
GUIStyle helpStyle = new GUIStyle(GUI.skin.label);
206+
helpStyle.fontSize = 16;
207+
Rect labelRect = new Rect(5, 20 * i, viewport.width - 100, 40);
208+
GUI.Label(labelRect, label,helpStyle);
209+
}
210+
GUI.EndScrollView();
211+
y += 100;
212+
}
190213
GUI.Box(new Rect(0,y,Screen.width,45), "");
191214
GUI.backgroundColor = new Color(0, 0, 0, 0);
192215
GUIStyle textStyle = new GUIStyle(GUI.skin.textField);

0 commit comments

Comments
 (0)