/// <summary> /// Actually submits a command /// Splits the arguments, checks if the command exists, calls the callback if it does and prints an error otherwise /// </summary> public override void Activate() { string[] parts = consoleGUI.input.Split(' '); string command = parts[0]; string[] args = parts.Skip(1).ToArray(); consoleLog.Log("> " + consoleGUI.input); if (consoleCommandsRepository.HasCommand(command)) { consoleLog.Log(consoleCommandsRepository.ExecuteCommand(command, args)); } else { consoleLog.Log("Command " + command + " not found"); } }
private void Submit() { if (inputField == null) { return; } if (forceSubmit) { string input = inputField.text; string[] parts = input.TrimStart().Split(' '); string command = parts[0]; string[] args = parts.Skip(1).ToArray(); consoleLog.Log("> " + input); if (consoleCommandsRepository.HasCommand(command)) { string response = consoleCommandsRepository.ExecuteCommand(command, args); if (response.Length > 0) { consoleLog.Log(response); } } else { if (command.Length > 0) { consoleLog.Log("Command \"" + command + "\" not found"); } } inputField.text = ""; forceSubmit = false; } }