Fixed Bug where WASD Movement worked when focused on Chat Input

This commit is contained in:
pelpanagiotis
2026-02-04 22:39:40 +02:00
parent 1a564d392a
commit 9bcb47d8f6
18 changed files with 182 additions and 1903 deletions

View File

@@ -15,11 +15,16 @@ public class ChatUI : MonoBehaviour
internal static string localPlayerName;
// Instance reference so static callers can check focus state safely
internal static ChatUI Instance;
private readonly List<string> lines = new();
private Player localPlayer;
void Awake()
{
Instance = this;
if (chatMessage != null)
{
chatMessage.onValueChanged.AddListener(ToggleButton);
@@ -27,6 +32,9 @@ public class ChatUI : MonoBehaviour
}
}
// Expose whether the chat input is focused so other systems can disable input/movement
public static bool IsInputFieldFocused => Instance != null && Instance.chatMessage != null && Instance.chatMessage.isFocused;
// Called by Player.OnStartLocalPlayer to connect the UI to the player's network methods.
public void Initialize(Player player)
{
@@ -102,6 +110,12 @@ public class ChatUI : MonoBehaviour
void OnDestroy()
{
if (chatMessage != null)
{
chatMessage.onValueChanged.RemoveListener(ToggleButton);
chatMessage.onSubmit.RemoveListener(OnInputSubmit);
}
// Clear static instance reference
if (Instance == this) Instance = null;
}
}