The save-dialog name field is a focused TMP_InputField, but global discrete hotkeys kept reading the keyboard every frame, so typing a name like "Checkers" cycled the pose (C) and shut the server down (K). Add a shared TypingGuard.IsTyping check (focused TMP/legacy InputField) and short-circuit the global handlers on it: pose cycle, network dev keys, mode switch, and paint undo/redo. Movement was already gated out via ControlEnabled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
973 B
C#
31 lines
973 B
C#
using UnityEngine.EventSystems;
|
|
using TMPro;
|
|
|
|
/// <summary>
|
|
/// True while the user is editing a focused on-screen text field (e.g. the paint HUD's
|
|
/// "save as" name input). Global gameplay/dev hotkeys consult this so typing a name like
|
|
/// "Checkers" doesn't also fire single-key shortcuts (C = cycle pose, K = shutdown,
|
|
/// the mode-switch key, Ctrl+Z = undo, ...).
|
|
/// </summary>
|
|
public static class TypingGuard
|
|
{
|
|
/// <summary>A text input field is currently focused and capturing keystrokes.</summary>
|
|
public static bool IsTyping
|
|
{
|
|
get
|
|
{
|
|
var es = EventSystem.current;
|
|
if (!es) return false;
|
|
|
|
var go = es.currentSelectedGameObject;
|
|
if (!go) return false;
|
|
|
|
var tmp = go.GetComponent<TMP_InputField>();
|
|
if (tmp) return tmp.isFocused;
|
|
|
|
var legacy = go.GetComponent<UnityEngine.UI.InputField>();
|
|
return legacy && legacy.isFocused;
|
|
}
|
|
}
|
|
}
|