private void Update() { // check if i'm pressing something instead. then i can check which button it is with a switch if (inputField.IsActive() && inputField.text.Length != 0 && Input.GetKeyDown(KeyCode.Return)) { console.ProcessCommand(text.text); } else if (inputField.IsActive() && inputField.text.Length != 0 && Input.GetKeyDown(KeyCode.Tab)) { string[] textArray = Regex.Split(inputField.text, @"( )"); // show arguments if previous index is a command foreach (ConsoleCommand command in console.commandsList.commands) { if (command.CommandWord.StartsWith(textArray[textArray.Length - 1])) { // show commands if multiple match textArray[textArray.Length - 1] = command.CommandWord; inputField.text = string.Concat(textArray); inputField.caretPosition = inputField.text.Length; return; } } } }
private void inputFocuser() { if (inputField.IsActive() == true && inputField.isFocused == false) { inputField.ActivateInputField(); } }
// Update is called once per frame private void Update() { if (EventSystem.current.currentSelectedGameObject == null) { if (studentNameField.IsActive()) { studentNameField.ActivateInputField(); } else if (studentSchoolField.IsActive()) { studentSchoolField.ActivateInputField(); } } if (Input.GetKeyDown(KeyCode.Return)) { if (studentNameField.IsActive()) { studentName = studentNameField.text; studentNameField.gameObject.SetActive(false); studentNameField.DeactivateInputField(); studentSchoolField.gameObject.SetActive(true); studentSchoolField.ActivateInputField(); } else { studentSchool = studentSchoolField.text; studentSchoolField.DeactivateInputField(); PostStudentData(studentName, studentSchool); mainMenu.SetFirstPlay(false); PlayerPrefs.SetInt("isFirstPlay", mainMenu.GetFirstPlay() ? 1 : 0); mainMenu.ToggleNotification(false, true, mainMenu.playButton); gameObject.SetActive(false); } } }