Catching Commands
This page describes how to easily catch potential commands from your players.
OnInputFieldCommandUpdated
private void OnInputFieldCommandUpdated(string command)
{
if (string.IsNullOrEmpty(command)) return;
// Assume _suggestions is a List of possible autocompletions
_suggestions.Clear();
// Filter suggestions based on the current command input
foreach (var suggestion in _possibleCommands)
{
if (suggestion.StartsWith(command, StringComparison.OrdinalIgnoreCase))
{
_suggestions.Add(suggestion);
}
}
// Show suggestions to the user
UpdateSuggestionsUI(_suggestions);
}
private void UpdateSuggestionsUI(List<string> suggestions)
{
// Code to update the UI with the suggestions goes here
}OnInputFieldCommandSubmitted
Last updated