void Update() { if (!input.isFocused) { EventSystem.current.SetSelectedGameObject(input.gameObject, null); input.OnPointerClick(new PointerEventData(EventSystem.current)); } }
public void Focus() { if (inputField == null) { return; } inputField.OnPointerClick(new PointerEventData(EventSystem.current)); }
void Focus() { if (!inputField.isFocused) { inputField.text = ""; EventSystem.current.SetSelectedGameObject(inputField.gameObject, null); inputField.OnPointerClick(new PointerEventData(EventSystem.current)); } }
public void SetCommandBlocked(bool blocked) { _blockCommands = blocked; _inputField.enabled = !blocked; if (!blocked) { _inputField.OnPointerClick(new PointerEventData(EventSystem.current)); _inputField.caretPosition = _inputField.text.Length; } }
/// <summary> /// Logt den im inputField eingegebenen Text in die Konsole und selektiert das inputField danach wieder. /// </summary> /// <param name="text"></param> public void LogStringFromInputField(string text) { LogStringToInGameConsole(text); if (text.StartsWith("/")) { ProcessCommand(text); } inputField.text = ""; inputField.Select(); inputField.OnPointerClick(new UnityEngine.EventSystems.PointerEventData(UnityEngine.EventSystems.EventSystem.current)); }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } EventSystem.current.SetSelectedGameObject(inputFieldPlayerName.gameObject, null); inputFieldPlayerName.OnPointerClick(new PointerEventData(EventSystem.current)); if (Input.GetKeyDown(KeyCode.Return)) { holdingObjects.playerTwoName = randomNamesForAi.namePlayerTwo; holdingObjects.inputFieldPlayerString = inputFieldPlayerName.text; SceneManager.LoadScene("MathDuel"); } }
private void Update() { if (UploadedPattern != null) { Confirm?.Invoke(UploadedPattern); Controller.Instance.Popup.Close(); UploadedPattern = null; } if (WasFocused && Input.GetKeyDown(KeyCode.Return)) { AddCurrentTag(); TagInputField.OnPointerClick(new UnityEngine.EventSystems.PointerEventData(null) { button = UnityEngine.EventSystems.PointerEventData.InputButton.Left }); } WasFocused = TagInputField.isFocused; }
private void Update() { UpdateScale(); if (!Application.isPlaying) { canvas.enabled = ShowPreview; } else { SuggestionsCount = InputParser.Instance.SuggestedCommands.Count; canvas.enabled = true; DisplayHistory(); DisplaySuggestions(); if (GameConsole.IsActive) { EventSystem.current.SetSelectedGameObject(CommandInputField.gameObject, null); CommandInputField.OnPointerClick(new PointerEventData(EventSystem.current)); } } }
private void SubmitCommand() { string cmd = input.text; // Entering no command if (cmd.Equals("")) { PrintLine("> "); return; } history.AddAfter(history.First, new LinkedListNode <string> (cmd)); input.text = ""; if (!(cmd.Equals("pan") || cmd.Equals("move"))) { EventSystem.current.SetSelectedGameObject(input.gameObject, null); input.OnPointerClick(new PointerEventData(EventSystem.current)); } PrintLine("> " + cmd); GetComponent <Commands> ().RunCommand(cmd); currCommand = history.First; }
/// <summary> /// Opens the chat window to send messages /// </summary> /// <param name="newChannel">The chat channels to select when opening it</param> public void OpenChatWindow(ChatChannel newChannel = ChatChannel.None) { //Prevent input spam if (windowCoolDown || UIManager.PreventChatInput) { return; } windowCoolDown = true; StartCoroutine(WindowCoolDown()); // Can't open chat window while main menu open if (GUI_IngameMenu.Instance.menuWindow.activeInHierarchy) { return; } var availChannels = GetAvailableChannels(); // Change the selected channel if one is passed to the function and it's available if (newChannel != ChatChannel.None && (availChannels & newChannel) == newChannel) { EnableChannel(newChannel); } else if (SelectedChannels == ChatChannel.None) { // Make sure the player has at least one channel selected TrySelectDefaultChannel(); } // Otherwise use the previously selected channels again EventManager.Broadcast(Event.ChatFocused); chatInputWindow.SetActive(true); background.SetActive(true); UIManager.IsInputFocus = true; // should work implicitly with InputFieldFocus EventSystem.current.SetSelectedGameObject(InputFieldChat.gameObject, null); InputFieldChat.OnPointerClick(new PointerEventData(EventSystem.current)); RefreshChannelPanel(); }
private void Update() { timer.MyUpdate(); if (Input.GetKeyDown(KeyCode.Escape)) { SceneManager.LoadScene("Menu"); Destroy(dontDestroyOnLoadObjects); } EventSystem.current.SetSelectedGameObject(inputeAnswer.gameObject, null); inputeAnswer.OnPointerClick(new PointerEventData(EventSystem.current)); if (Input.GetKeyDown(KeyCode.Return) && inputeAnswer.ToString() != System.String.Empty) { Answer(); } if (timer.newGameTime <= 0 && timer.isNewGameTime) { NewQuestion(); timer.isNewGameTime = false; } if (timer.showingAnswerTime <= 0 && timer.isShowingAnswerTime) { RestartGame(); timer.isShowingAnswerTime = false; } if (timer.newQuestionTime <= 0 && timer.isNewQuestionTime) { DrawOutTextWinnerText(); timer.isNewQuestionTime = false; } if (timer.newQuestionTime <= 0 && rounds >= 5) { } }
/// <summary> /// Update the "alpha" of each line and update the background size. /// </summary> protected virtual void Update() { if (activateOnReturnKey && (Input.GetKeyUp(KeyCode.Return) || Input.GetKeyUp(KeyCode.KeypadEnter))) { if (!mIgnoreNextEnter) { input.interactable = true; input.Select(); input.ActivateInputField(); EventSystem.current.SetSelectedGameObject(input.gameObject, null); input.OnPointerClick(new PointerEventData(EventSystem.current)); } mIgnoreNextEnter = false; } int height = 0; for (int i = 0; i < mChatEntries.Count;) { ChatEntry e = mChatEntries[i]; float alpha; if (e.isExpired) { // Quickly fade out expired chat entries alpha = Mathf.Clamp01(e.alpha - Time.unscaledDeltaTime); } else if (!allowChatFading || Time.unscaledTime - e.time < fadeOutStart) { // Quickly fade in new entries alpha = Mathf.Clamp01(e.alpha + Time.unscaledDeltaTime * 5f); } else if (Time.unscaledTime - (e.time + fadeOutStart) < fadeOutDuration) { // Slowly fade out entries that have been visible for a while alpha = Mathf.Clamp01(e.alpha - Time.unscaledDeltaTime / fadeOutDuration); } else { // Quickly fade out chat entries that should have faded by now, // but likely didn't due to the input being selected. alpha = Mathf.Clamp01(e.alpha - Time.unscaledDeltaTime); } if (e.alpha != alpha) { e.alpha = alpha; if (!e.fadedIn && !e.isExpired) { // This label has not yet faded in, we want to scale it in, // as it looks better and goes well with the scaled background. float labelHeight = Mathf.Lerp(0.001f, 1f, e.alpha); e.transform.localScale = new Vector3(1f, labelHeight, 1f); } // Fade in or fade out the label //if (e.label.bitmapFont != null && e.label.bitmapFont.premultipliedAlphaShader) //{ // e.label.color = Color.Lerp(new Color(0f, 0f, 0f, 0f), e.color, e.alpha); /*} * else * { * e.label.alpha = e.alpha; * }*/ e.group.alpha = e.alpha; if (alpha == 1f) { // The chat entry has faded in fully e.fadedIn = true; } else if (alpha == 0f && e.shouldBeDestroyed) { // This chat entry has expired and should be removed mChatEntries.RemoveAt(i); Destroy(e.label.gameObject); continue; } } // If the line is visible, it should be counted if (e.alpha > 0.01f) { height += e.lines * (int)e.label.rectTransform.sizeDelta.y; } ++i; } // Resize the background if its height has changed //if (background != null && mBackgroundHeight != height) // ResizeBackground(height, !allowChatFading); }
private void FocusAndSelectAllInInputField() { EventSystem.current.SetSelectedGameObject(m_userInputField.gameObject, null); m_userInputField.OnPointerClick(new PointerEventData(EventSystem.current)); }
public void SubmitLetter() { PlayerBehaviour player = GameManager.Instance.players[GameManager.Instance.currentPlayer]; if (GameManager.Instance.gamePhaseManager.CheckPhase(GamePhase.SPIN)) { return; } if (solve.activeInHierarchy && GameManager.Instance.gamePhaseManager.CheckPhase(GamePhase.SOLVE)) { guessSolve = tmpSolveField.text; NetworkMatchLoop.Instance.SendGameUpdate(); // Send after each guess if (!display.Solve(tmpSolveField.text, ref player)) { StartCoroutine(LoseTurn()); } else { // Sets the input field to selected EventSystem.current.SetSelectedGameObject(tmpInputField1.gameObject, null); tmpInputField1.OnPointerClick(new PointerEventData(EventSystem.current)); } // Show player's current score player.DisplayScore(); tmpSolveField.text = ""; tmpInputField1.Select(); solve.SetActive(false); guess.SetActive(true); GameManager.Instance.gamePhaseManager.SetPhase(GamePhase.SELECT); guessSolve = ""; } else if (guess.activeInHierarchy && GameManager.Instance.gamePhaseManager.CheckPhase(GamePhase.GUESS)) { if (tmpInputField1.text != "") { int scoreVal = GameManager.Instance.roulette.GetSpinResult(); guessChar = (tmpInputField1.text.ToCharArray())[0]; NetworkMatchLoop.Instance.SendGameUpdate(); // Send after each guess // Clears the guess if (!display.MakeGuess(guessChar, ref player, scoreVal)) { StartCoroutine(LoseTurn()); } else { // Sets the input field to selected EventSystem.current.SetSelectedGameObject(tmpInputField1.gameObject, null); tmpInputField1.OnPointerClick(new PointerEventData(EventSystem.current)); } // Show player's current score player.DisplayScore(); tmpInputField1.text = ""; tmpInputField1.Select(); GameManager.Instance.gamePhaseManager.SetPhase(GamePhase.SELECT); guessChar = '\0'; } } }
private void SelectSearchField() { Select(_searchInputField.gameObject); _searchInputField.OnPointerClick(new PointerEventData(_eventSystem)); }
// Focus on the input field for the chat box void FocusOnInput() { EventSystem.current.SetSelectedGameObject(inputField.gameObject, null); inputField.OnPointerClick(new PointerEventData(EventSystem.current)); }
private void FocusInput() { EventSystem.current.SetSelectedGameObject(field.gameObject, null); field.OnPointerClick(new PointerEventData(EventSystem.current)); }