Iteration 4 over Assets/Scripts (no component/file splits, no Unity assets touched): Dedup: - Route inline cursor-release, material guards, Ctrl-held and undo/redo input through existing InputUtil / SetMatFloat helpers - Add ungated InputUtil.KeyPressedThisFrame; GameplayKeyPressed builds on it - Unify FindDeep/FindDeepChild into GeometryUtil.FindDeep Dead code / stale docs: - Remove unused code-gen bake path (HsvColorPicker.Build, PaintHud factory) - Drop unreferenced symbols (SubPhaseChanged event, LocalPhaseDuration, IsLocalSceneMain, MouseSensitivity.Changed, IsPaused, InSession, NetworkControlled, PreviousPose, JointCount, voxel-count accessors) - Fix incorrect PlayerRole / PaintHud / Pick / PlayerPose docs Perf / robustness (behaviour-neutral): - ConcealmentMeter.Evaluate: reuse vertex/topology buffers, two-pointer crossing count - BuildMeshCaches: alloc-free vertex copy, cached topology/UVs - Guard all PlayerPaintSync LogSync sites behind logSync - Cache LocalViewerIsHunter / controller / CanShoot / TypingGuard lookups; dedup LocalIsHunter with MatchHud - Change-guard RefreshEmissionColor and HeroCutout.Disarm - Cache scene/countdown string comparisons per frame - Grow NonAlloc buffers and log-once on saturation Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using UnityEngine;
|
|
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
|
|
{
|
|
// Consulted several times per frame by the hotkey readers; the GetComponent lookups are cached
|
|
// per selected GameObject (a selection change refreshes them).
|
|
private static GameObject _cachedGo;
|
|
private static TMP_InputField _cachedTmp;
|
|
private static UnityEngine.UI.InputField _cachedLegacy;
|
|
|
|
/// <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;
|
|
|
|
if (go != _cachedGo)
|
|
{
|
|
_cachedGo = go;
|
|
_cachedTmp = go.GetComponent<TMP_InputField>();
|
|
_cachedLegacy = _cachedTmp ? null : go.GetComponent<UnityEngine.UI.InputField>();
|
|
}
|
|
|
|
if (_cachedTmp) return _cachedTmp.isFocused;
|
|
return _cachedLegacy && _cachedLegacy.isFocused;
|
|
}
|
|
}
|
|
}
|