Reorganize scripts into subfolders by responsibility

Move scripts under Assets/Scripts/ into Components, GameMode, Helper,
Network, Enum, Struct and ScriptableObject folders. Pure file moves
(plus folder .meta files); no code changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-07-02 15:02:15 +02:00
1 parent 382bfb36df
commit e23fae0c50
126 files changed
+112

No files matched your search

@@ -0,0 +1,21 @@
using UnityEngine;
/// <summary>Disables a CharacterController around a transform write so it cannot snap the transform back.</summary>
public static class CharacterTeleport
{
public static void Move(CharacterController cc, Transform t, Vector3 position)
{
bool reenable = cc && cc.enabled;
if (cc) cc.enabled = false;
t.position = position;
if (cc) cc.enabled = reenable;
}
public static void Move(CharacterController cc, Transform t, Vector3 position, Quaternion rotation)
{
bool reenable = cc && cc.enabled;
if (cc) cc.enabled = false;
t.SetPositionAndRotation(position, rotation);
if (cc) cc.enabled = reenable;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 52a1fdeaf96581840bc09373ff2c7ad0
+55
View File
@@ -0,0 +1,55 @@
using System.Collections.Generic;
using UnityEngine;
/// <summary>Shared mesh/bounds/hierarchy helpers.</summary>
public static class GeometryUtil
{
/// <summary>Depth-first hierarchy search by name; checks <paramref name="root"/> itself first.</summary>
public static Transform FindDeep(Transform root, string name)
{
if (root.name == name) return root;
for (int i = 0; i < root.childCount; i++)
{
var found = FindDeep(root.GetChild(i), name);
if (found) return found;
}
return null;
}
/// <summary>Divides a world scale back out of a freshly baked mesh so it is true unit-scale local
/// geometry (BakeMesh freezes the transform's lossyScale into the vertices). No-op at scale 1;
/// <paramref name="scratch"/> is reused so nothing is allocated per bake.</summary>
public static void RescaleToUnitScale(Mesh baked, Vector3 lossyScale, List<Vector3> scratch)
{
if (lossyScale.x == 1f && lossyScale.y == 1f && lossyScale.z == 1f) return;
float ix = lossyScale.x != 0f ? 1f / lossyScale.x : 0f;
float iy = lossyScale.y != 0f ? 1f / lossyScale.y : 0f;
float iz = lossyScale.z != 0f ? 1f / lossyScale.z : 0f;
baked.GetVertices(scratch);
for (int i = 0; i < scratch.Count; i++)
{
Vector3 v = scratch[i];
v.x *= ix; v.y *= iy; v.z *= iz;
scratch[i] = v;
}
baked.SetVertices(scratch);
baked.RecalculateBounds();
}
/// <summary>World AABB enclosing a local AABB after an affine transform (encapsulates the 8 transformed corners).</summary>
public static Bounds TransformBounds(Matrix4x4 m, Bounds local)
{
Vector3 mn = local.min, mx = local.max;
Vector3 c0 = m.MultiplyPoint3x4(mn);
Bounds b = new Bounds(c0, Vector3.zero);
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mx.x, mn.y, mn.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mn.x, mx.y, mn.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mn.x, mn.y, mx.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mx.x, mx.y, mn.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mx.x, mn.y, mx.z)));
b.Encapsulate(m.MultiplyPoint3x4(new Vector3(mn.x, mx.y, mx.z)));
b.Encapsulate(m.MultiplyPoint3x4(mx));
return b;
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: deab7e342bb598049b9972454a8399e5
+122
View File
@@ -0,0 +1,122 @@
using UnityEngine;
#if ENABLE_INPUT_SYSTEM
using UnityEngine.InputSystem;
#endif
/// <summary>
/// Shared low-level input reads used by the camera rigs, the paint controller and the modes. Each
/// method preserves its original per-backend behaviour (new Input System when present, legacy Input
/// Manager otherwise). Sensitivity scaling stays at the call sites.
/// </summary>
public static class InputUtil
{
/// <summary>Raw mouse delta this frame (pixels); the legacy path scales GetAxisRaw by 10 to match.</summary>
public static Vector2 ReadMouseDelta()
{
#if ENABLE_INPUT_SYSTEM
return Mouse.current != null ? Mouse.current.delta.ReadValue() : Vector2.zero;
#else
return new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y")) * 10f;
#endif
}
/// <summary>Raw mouse-wheel delta this frame (usually only its sign is used).</summary>
public static float ReadScroll()
{
#if ENABLE_INPUT_SYSTEM
if (Mouse.current != null) return Mouse.current.scroll.ReadValue().y;
#endif
#if ENABLE_LEGACY_INPUT_MANAGER
return Input.GetAxis("Mouse ScrollWheel");
#else
return 0f;
#endif
}
/// <summary>Locks+hides or frees+shows the hardware cursor.</summary>
public static void SetCursorLocked(bool locked)
{
Cursor.lockState = locked ? CursorLockMode.Locked : CursorLockMode.None;
Cursor.visible = !locked;
}
public static bool ShiftHeld()
{
#if ENABLE_INPUT_SYSTEM
var kb = Keyboard.current;
if (kb != null) return kb.leftShiftKey.isPressed || kb.rightShiftKey.isPressed;
#endif
#if ENABLE_LEGACY_INPUT_MANAGER
return Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
#else
return false;
#endif
}
public static bool CtrlHeld()
{
#if ENABLE_INPUT_SYSTEM
var kb = Keyboard.current;
if (kb != null) return kb.leftCtrlKey.isPressed || kb.rightCtrlKey.isPressed;
#endif
#if ENABLE_LEGACY_INPUT_MANAGER
return Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);
#else
return false;
#endif
}
public static bool LeftMouseHeld()
{
#if ENABLE_INPUT_SYSTEM
return Mouse.current != null && Mouse.current.leftButton.isPressed;
#else
return Input.GetMouseButton(0);
#endif
}
public static bool RightMouseHeld()
{
#if ENABLE_INPUT_SYSTEM
return Mouse.current != null && Mouse.current.rightButton.isPressed;
#else
return Input.GetMouseButton(1);
#endif
}
public static bool MiddleMouseHeld()
{
#if ENABLE_INPUT_SYSTEM
return Mouse.current != null && Mouse.current.middleButton.isPressed;
#else
return Input.GetMouseButton(2);
#endif
}
/// <summary>Left mouse button pressed on this exact frame (edge, not held).</summary>
public static bool LeftClickedThisFrame()
{
#if ENABLE_INPUT_SYSTEM
return Mouse.current != null && Mouse.current.leftButton.wasPressedThisFrame;
#else
return Input.GetMouseButtonDown(0);
#endif
}
/// <summary>Key pressed on this exact frame (edge), regardless of UI focus. The parameter type
/// follows the active input backend, matching how the callers' serialized key fields are declared.</summary>
#if ENABLE_INPUT_SYSTEM
public static bool KeyPressedThisFrame(Key key)
=> Keyboard.current != null && Keyboard.current[key].wasPressedThisFrame;
#else
public static bool KeyPressedThisFrame(KeyCode key) => Input.GetKeyDown(key);
#endif
/// <summary>Gameplay key pressed on this exact frame (edge), suppressed while a UI text field is
/// focused so typing never triggers gameplay bindings.</summary>
#if ENABLE_INPUT_SYSTEM
public static bool GameplayKeyPressed(Key key) => !TypingGuard.IsTyping && KeyPressedThisFrame(key);
#else
public static bool GameplayKeyPressed(KeyCode key) => !TypingGuard.IsTyping && KeyPressedThisFrame(key);
#endif
}
+2
View File
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 9ec32d583d2203244b854643c78360d4
+41
View File
@@ -0,0 +1,41 @@
using UnityEngine;
/// Global mouse look-around sensitivity multiplier, shared by every camera
/// controller (FreeCam, FirstPerson, ThirdPersonOrbit). 1 = unchanged baseline.
/// Persisted per-machine via PlayerPrefs so the setting survives restarts.
public static class MouseSensitivity
{
public const float Default = 1f;
public const float Min = 0.1f;
public const float Max = 4f;
const string PrefKey = "Settings.MouseSensitivity";
static bool _loaded;
static float _multiplier = Default;
public static float Multiplier
{
get
{
if (!_loaded)
{
_loaded = true;
_multiplier = Mathf.Clamp(PlayerPrefs.GetFloat(PrefKey, Default), Min, Max);
}
return _multiplier;
}
set
{
float v = Mathf.Clamp(value, Min, Max);
_loaded = true;
if (Mathf.Approximately(v, _multiplier)) return;
_multiplier = v;
PlayerPrefs.SetFloat(PrefKey, v);
// Flush to disk now so the setting survives a hard kill (build), not
// only a clean quit. Settings changes are rare user actions, so the
// extra write is negligible.
PlayerPrefs.Save();
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5dc578039be8b9e48a2260d640ffcfc1
+41
View File
@@ -0,0 +1,41 @@
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;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c30f56f99c2725a4e861c19a5e83e0aa