diff --git a/NitroxClient/GameLogic/ChatUI/PlayerChatManager.cs b/NitroxClient/GameLogic/ChatUI/PlayerChatManager.cs index 27b4ea3c65..db622dd731 100644 --- a/NitroxClient/GameLogic/ChatUI/PlayerChatManager.cs +++ b/NitroxClient/GameLogic/ChatUI/PlayerChatManager.cs @@ -64,6 +64,13 @@ private IEnumerator SelectChatAsync() } } + public void DeselectChat() => Player.main.StartCoroutine(DeselectChatAsync()); + private IEnumerator DeselectChatAsync() + { + yield return new WaitUntil(() => PlayerChat.IsReady); + playerChat.Deselect(); + } + public void AddMessage(string playerName, string message, Color color) => Player.main.StartCoroutine(AddMessageAsync(playerName, message, color)); private IEnumerator AddMessageAsync(string playerName, string message, Color color) { diff --git a/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChatInputField.cs b/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChatInputField.cs index 2ac0c0dd82..6e43c8a7c8 100644 --- a/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChatInputField.cs +++ b/NitroxClient/MonoBehaviours/Gui/Chat/PlayerChatInputField.cs @@ -113,10 +113,11 @@ private void Update() sentMessages.Add(InputField.text); _sentMessagesIndex = sentMessages.Count; playerChatManager.SendMessage(); + playerChatManager.DeselectChat(); // return to game after message sent } } } - + // Chat history stuff // GetKeyDown means it's only getting executed once per press if (UnityEngine.Input.GetKeyDown(KeyCode.UpArrow)) @@ -153,6 +154,12 @@ private void Update() FreezeTime = true; } } + + // Reselect chat if Y is pressed + if (UnityEngine.Input.GetKeyDown(KeyCode.Y)) + { + playerChatManager.SelectChat(); + } } private IEnumerator MoveToEndOfText()