Refactor scripts: dedup remainder, remove dead code, perf hardening

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>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-07-02 13:33:18 +02:00
1 parent 2243cc823e
commit 382bfb36df
32 files changed
+292 -348

No files matched your search

+9 -7
View File
@@ -11,8 +11,8 @@ using UnityEngine.InputSystem;
/// uGUI binding for <see cref="OnlineSessionManager"/>. Drives the server-browser canvas - Host / Refresh /
/// pick a row / Join / Disconnect plus a status line - and mirrors the manager's state through its
/// <see cref="OnlineSessionManager.Changed"/> / <see cref="OnlineSessionManager.SessionsChanged"/> events.
/// Replaces the old IMGUI browser. Lives on the browser canvas; the session logic stays on the
/// NetworkManager's <see cref="OnlineSessionManager"/>.
/// Lives on the browser canvas; the session logic stays on the NetworkManager's
/// <see cref="OnlineSessionManager"/>.
///
/// Selection model: Refresh fills the list with clones of <see cref="entryTemplate"/> (each a clickable row
/// showing name + player count). Clicking a row selects it; Join connects to the selected session. While
@@ -66,7 +66,7 @@ public class OnlineSessionBrowserUI : MonoBehaviour
private bool _open; // Esc-toggled visibility while connected
private bool _connected; // last-seen connection state (to detect transitions)
private string _lastScene; // last-seen active scene name (to auto-close on a scene change)
private Scene _lastScene; // last-seen active scene (to auto-close on a scene change)
private string _disconnectText; // last applied caption (avoids per-frame TMP churn)
private void Awake()
@@ -122,8 +122,9 @@ public class OnlineSessionBrowserUI : MonoBehaviour
// Auto-close the overlay if the scene changed underneath it (a remote ended/started the match, or
// we walked into Start Match) so it never lingers as a stale pause across a transition.
string scene = SceneManager.GetActiveScene().name;
if (connected && _open && _lastScene != null && scene != _lastScene)
// Compared as Scene structs (handles), not names, so nothing is allocated per frame.
Scene scene = SceneManager.GetActiveScene();
if (connected && _open && _lastScene.IsValid() && scene != _lastScene)
SetOpen(false);
_lastScene = scene;
@@ -301,12 +302,13 @@ public class OnlineSessionBrowserUI : MonoBehaviour
return t ? t.GetComponent<TMP_Text>() : null;
}
// NOT TypingGuard-gated (GameplayKeyPressed): Esc must close the panel even while a text field has focus.
private static bool EscapePressed()
{
#if ENABLE_INPUT_SYSTEM
return Keyboard.current != null && Keyboard.current.escapeKey.wasPressedThisFrame;
return InputUtil.KeyPressedThisFrame(Key.Escape);
#else
return Input.GetKeyDown(KeyCode.Escape);
return InputUtil.KeyPressedThisFrame(KeyCode.Escape);
#endif
}
}