Skip to content

fix: capture Device Simulator rendering via PlayModeView#1766

Merged
hatayama merged 3 commits into
feature/simulator-view-supportfrom
fix/gameview-bridge-playmodeview
Jul 14, 2026
Merged

fix: capture Device Simulator rendering via PlayModeView#1766
hatayama merged 3 commits into
feature/simulator-view-supportfrom
fix/gameview-bridge-playmodeview

Conversation

@hatayama

@hatayama hatayama commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Refs: MasaVault 2026-07-14_シミュレーターモードでのマウスシミュレート調査.md PR-1 (To-Do 2–9)

Summary

  • GameViewBridge now resolves the active Play Mode view through PlayModeView.GetMainPlayModeView() and reads m_TargetTexture from the PlayModeView declaring type, so Device Simulator (SimulatorWindow) rendering screenshots work the same as Game View.
  • Screenshot unavailable-texture warnings/comments mention Game View and Device Simulator.
  • Added pure unit tests for the base-type GetField pitfall plus a resolution smoke test.

User Impact

  • With the Game tab set to Device Simulator in Play Mode, uloop screenshot --capture-mode rendering (including --annotate-elements) returns a PNG again, so the annotate → simulate-mouse-ui click flow unblocks.

Test plan

  • dist/darwin-arm64/uloop compile → 0 errors / 0 warnings
  • GameViewBridgeTests + EditorWindowCaptureUtilityTests EditMode → passed
  • Simulator + Play Mode (SimulateMouseDemoScene): rendering screenshot, annotate-elements, click ClickButton1[Demo] Clicked 'ClickButton1'
  • Normal Game View regression: same three steps succeed
  • Simulator Fit to Screen / Scale / portrait rotation / Safe Area ON: annotate → click still hits
  • GHA: not applicable on this PR — base is the umbrella branch feature/simulator-view-support (workflows only run for main / v3-beta). Full GHA runs on the final umbrella → v3-beta PR. Quality here is local verification + review.

Notes

  • Full EditMode run: 2030 passed, 2 failed in unrelated suites (RunTestsTestFrameworkResultTests, StaticFacadeStateGuardTests); not caused by this change.
  • Fit/Scale/Safe Area are chrome-only; input coordinates stay in game-resolution space. Portrait rotation changes Screen size — re-annotate after rotating (verified).

hatayama and others added 3 commits July 14, 2026 09:41
Device Simulator uses SimulatorWindow, not GameView, so looking up
UnityEditor.GameView left rendering screenshots empty. Resolve the
active view through PlayModeView.GetMainPlayModeView and read
m_TargetTexture from the PlayModeView declaring type.

Co-authored-by: Cursor <cursoragent@cursor.com>
Rendering capture now works for Game View and Device Simulator, so
unavailable-texture guidance and comments should mention both instead
of GameView-only wording.

Co-authored-by: Cursor <cursoragent@cursor.com>
Cover the reflection pitfall that private base fields are invisible to
GetField on derived types, and smoke-test member resolution.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

GameViewBridge now obtains the Play Mode view’s RenderTexture through PlayModeView reflection. New editor tests cover private field resolution, while screenshot comments and messages use Play Mode view terminology.

Changes

Play Mode capture

Layer / File(s) Summary
PlayModeView reflection bridge
Packages/src/Editor/InternalAPIBridge/...
GameViewBridge resolves PlayModeView.GetMainPlayModeView() and reads m_TargetTexture; friend-assembly access is added for editor tests.
Reflection behavior tests
Assets/Tests/Editor/GameViewBridgeTests.cs
Tests cover declaring-type field lookup, derived-type private-field behavior, and successful render-texture retrieval.
Capture messaging and documentation
Packages/src/Editor/FirstPartyTools/Screenshot/...
Capture comments and messages now refer to the Play Mode view and its RenderTexture.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ScreenshotCapture
  participant GameViewBridge
  participant PlayModeView
  ScreenshotCapture->>GameViewBridge: Request render texture
  GameViewBridge->>PlayModeView: Invoke GetMainPlayModeView
  PlayModeView-->>GameViewBridge: Return main Play Mode view
  GameViewBridge->>PlayModeView: Read m_TargetTexture
  PlayModeView-->>GameViewBridge: Return RenderTexture
  GameViewBridge-->>ScreenshotCapture: Return RenderTexture or null
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: capturing Device Simulator rendering via PlayModeView.
Description check ✅ Passed The description is directly related to the changes and accurately describes the PlayModeView rendering fix and tests.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gameview-bridge-playmodeview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hatayama
hatayama merged commit fe39a68 into feature/simulator-view-support Jul 14, 2026
2 checks passed
@hatayama
hatayama deleted the fix/gameview-bridge-playmodeview branch July 14, 2026 00:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant