Files
Shutong Wu c56337ec03 refactor: drop defensive scaffolding made obsolete by module dep declarations (#1122)
Since #1122 declared the Physics 2D, Screen Capture, Image Conversion, etc.
built-in modules as required deps in package.json, Unity Package Manager now
keeps them enabled while MCP for Unity is installed. Two defensive layers
that protected against the now-impossible "module disabled" case become dead
code, plus one sub-floor preprocessor gate that was always-true on our
declared `unity: 2021.3` floor.

Tier 1A — UnityPhysicsCompat.cs
- Revert `Type.GetType("UnityEngine.Physics2D, UnityEngine.Physics2DModule")`
  to `typeof(Physics2D)`. The property-level reflection (for `autoSyncTransforms`
  deprecation in Unity 6.x) stays — that's a different concern.

Tier 1B — TrailControl.cs
- Strip `#if UNITY_2021_1_OR_NEWER` gate. Package floor is 2021.3 per
  package.json, so the `#else` branch ("AddPosition requires Unity 2021.1+")
  is unreachable.

Tier 2 — ScreenshotUtility.cs + callers
- Remove `IsScreenCaptureModuleAvailable` property, `ScreenCaptureModuleNotAvailableError`
  constant, `InvokeCaptureScreenshotAsTexture` helper, and the
  `s_captureScreenshotMethod` / `s_captureScreenshotAsTextureMethod` /
  `s_screenCaptureModuleAvailable` reflection caches.
- Replace reflective `MethodInfo.Invoke` calls with direct `ScreenCapture.X`
  calls in `CaptureToProjectFolder`, `CaptureComposited`, and the
  `ScreenshotCapturer` MonoBehaviour.
- Camera-based fallback path (`FindAvailableCamera` + `CaptureFromCameraToProjectFolder`)
  is preserved — it still handles transient null returns from `ScreenCapture`
  inside `CaptureComposited`.
- Drop pre-flight `if (!IsScreenCaptureModuleAvailable)` gates in
  `ManageUI.cs` (UI render) and `ManageScene.cs` (screenshot path).
- `ProjectInfo` resource: `screenCapture` field is now an invariant `true`
  (preserves API shape for `mcpforunity://project/info` consumers).

Net: 144 lines removed, 15 added. No new tests — the changes are pure
removal of code paths that cannot fire with the current deps declared.

Related: #1160, #1122.
2026-05-26 16:13:00 +08:00
..
2026-04-03 23:39:11 -04:00
2026-01-07 18:51:51 -04:00
Fix
2026-04-04 00:01:31 -04:00
Fix
2026-04-04 00:01:31 -04:00
Fix
2026-04-04 00:01:31 -04:00