Skip to content

Commit 68c1284

Browse files
committed
pressing enter while navigating suggestions will auto complete instead of submit, also fixed commands text input field not selecting when opening console
1 parent 26885a3 commit 68c1284

File tree

11 files changed

+2972
-1875
lines changed

11 files changed

+2972
-1875
lines changed

Assets/HuntroxGames/CommandConsole/Examples/Scripts/ConsoleMenuTrigger.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

Assets/HuntroxGames/CommandConsole/Examples/Scripts/ConsoleMenuTrigger.cs.meta

Lines changed: 0 additions & 11 deletions
This file was deleted.

Assets/HuntroxGames/CommandConsole/Resources/WhiteRabbit-47pD SDF.asset

Lines changed: 47 additions & 21 deletions
Large diffs are not rendered by default.

Assets/HuntroxGames/CommandConsole/Scripts/Core/ConsoleUIMenu.cs

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ConsoleUIMenu : CommandConsole
2929
[SerializeField] private RectTransform suggestionParent;
3030
[SerializeField] private Color suggestionTextColor = Color.white;
3131
[SerializeField] private Color selectedSuggestionTextColor = new Color32(65, 183, 25, 255);
32-
32+
3333
private string commandInput = "";
3434

3535
private RectTransform suggestionContent;
@@ -47,6 +47,12 @@ private void Start()
4747

4848
private void OnConsoleInputSubmit(string value)
4949
{
50+
if (suggestionParent.gameObject.activeSelf)
51+
{
52+
AutoComplete();
53+
return;
54+
}
55+
5056
HandleCommandInput(value, InsertLog);
5157
consoleInputField.text = "";
5258
consoleInputField.Select();
@@ -184,12 +190,7 @@ private void Update()
184190

185191
if (Input.GetKeyDown(autoCompletionKey))
186192
{
187-
var autoComplete = commandSuggestion.AutoComplete(false);
188-
if (!autoComplete.IsNullOrEmpty())
189-
{
190-
consoleInputField.text = autoComplete;
191-
consoleInputField.MoveTextEnd(false);
192-
}
193+
AutoComplete();
193194
}
194195

195196
//if(!isActive) return;
@@ -207,11 +208,25 @@ private void Update()
207208
}
208209
}
209210

211+
private void AutoComplete()
212+
{
213+
var autoComplete = commandSuggestion.AutoComplete(false);
214+
if (!autoComplete.IsNullOrEmpty())
215+
{
216+
consoleInputField.Select();
217+
consoleInputField.ActivateInputField();
218+
consoleInputField.MoveToEndOfLine(false, true);
219+
consoleInputField.text = autoComplete;
220+
consoleInputField.MoveTextEnd(false);
221+
}
222+
}
223+
210224
[ConsoleCommand]
211225
private void ClearConsole()
212226
{
213227
logList.Clear();
214228
consoleHistory.Clear();
229+
content.DestroyAllChildren();
215230
LoadSuggestions();
216231
UpdateLayout();
217232
}
@@ -248,14 +263,12 @@ protected override void OnUnityLogMessageReceived(string condition, string stack
248263
public override void ToggleConsole()
249264
{
250265
base.ToggleConsole();
251-
if (isActive)
252-
{
253-
UpdateLayout();
254-
consoleInputField.SetTextWithoutNotify("");
255-
consoleInputField.Select();
256-
consoleInputField.ActivateInputField();
257-
}
258266
uiParentPanel.gameObject.SetActive(isActive);
267+
if (!isActive) return;
268+
UpdateLayout();
269+
consoleInputField.SetTextWithoutNotify("");
270+
consoleInputField.Select();
271+
consoleInputField.ActivateInputField();
259272
}
260273
}
261274
}

Assets/HuntroxGames/CommandConsole/Scripts/Core/SuggestionTextUI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using UnityEngine;
22
using UnityEngine.Events;
33
using UnityEngine.EventSystems;
4-
using UnityEngine.UI;
54

65
namespace HuntroxGames.Utils
76
{

0 commit comments

Comments
 (0)