22using System . Collections ;
33using System . Collections . Generic ;
44using UnityEngine ;
5+ using UnityEngine . UI ;
56
67public 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