Skip to content

chore: Add raycast grid annotation infrastructure for an upcoming screenshot capability - #1660

Merged
hatayama merged 1 commit into
v3-betafrom
feat/raycast-grid-annotation
Jul 9, 2026
Merged

hatayama merged 1 commit into
v3-betafrom
feat/raycast-grid-annotation

Conversation

@hatayama

@hatayama hatayama commented Jul 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Ports the raycast grid annotation infrastructure from main (RaycastGridAnnotator, RaycastHitClusterer, RaycastLayerMaskResolver, RaycastSampleOutlineBuilder) so a later PR can wire it into the screenshot tool.
  • Extracts a reusable UiRaycastHelper.RaycastContext so repeated UI-occlusion raycasts (up to 1600 per screenshot capture) can reuse cached Canvas/EventSystem state instead of rescanning every sample.

User Impact

  • No visible behavior change yet — these classes are not called by any tool in this PR. They exist so the upcoming screenshot raycast-grid feature can build on them.
  • Existing UI raycast behavior (mouse-click simulation, drag targeting, input replay) is unchanged; RaycastUI now delegates to RaycastContext internally but keeps identical hit-testing semantics.

Changes

  • Added RaycastGridAnnotator/RaycastHitClusterer/RaycastLayerMaskResolver/RaycastSampleOutlineBuilder under FirstPartyTools/Screenshot/RaycastAnnotation/ (only the screenshot tool uses these on main, so no new shared Common module was introduced).
  • Added RaycastGridPointInfo, RaycastLayerSummaryInfo, RaycastOutlineSegment to ToolContracts, and extended UIElementInfo with Layer/Components/RaycastOutlineSegments.
  • Extracted CollectCanvasRaycastSources/RaycastCanvasSpaceFromSources from the existing UiRaycastHelper.RaycastCanvasSpace, and built a new RaycastContext on top of them. Kept this repo's existing (more correct) IsRaycastCandidate filtering instead of copying main's older logic, to avoid two divergent UI hit-testing implementations.
  • Ported RaycastGridAnnotatorTests.cs (30 tests) with a what-comment on each test.

Verification

  • uloop compile: 0 errors, 0 warnings
  • RaycastGridAnnotatorTests (30/30 green)
  • MouseUiDragTargetResolverTests + MouseUiPointerTargetResolverTests (EditMode, 13/13 green)
  • SimulateMouseUiTests + SimulateMouseUiInputSystemTests + InputReplayVerificationE2ETests (PlayMode, 34/34 + 2/2 green) — confirms the UiRaycastHelper refactor has no behavior regression for existing callers

Review in cubic

origin/mainの最終形からRaycastGridAnnotator/RaycastHitClusterer/
RaycastLayerMaskResolver/RaycastSampleOutlineBuilderを移植した。
main実装をレビューしたFable5の指摘に基づき、以下をmainの構成から変更している:

- 配置場所: main側はRaycastToolとScreenshotTool両方から使われる想定でUtils/直下に
  置かれていたが、実際の利用元はScreenshotToolのみだったため、新規共有asmdefを作らず
  FirstPartyTools/Screenshot/RaycastAnnotation/サブフォルダに配置した(YAGNI)。
- UIElementInfo拡張: RaycastGridAnnotatorがLayer/Components/RaycastOutlineSegments
  フィールドに代入するため、UIElementInfo(ToolContracts)にこの3フィールドを先行追加した。
  RaycastOutlineSegment型もCommonではなくToolContractsに新設(ToolContractsはCommonを
  参照できない最下層のため)。
- UiRaycastHelperにRaycastContextを追加: グリッド全点(最大40x40=1600サンプル)の
  UI occlusion判定でCanvas全走査を毎回繰り返すとUnity Freeze Prevention上の懸念があるため、
  main同様にCanvas走査結果をキャッシュするRaycastContextを追加した。ただしmain版を
  逐語コピーすると、v3-beta独自に入っていた正しさ修正(子Canvas帰属チェック、
  ignoreReversedGraphics対応)が失われ、スクリーンショットのocclusion判定と
  simulate-mouse-uiのクリック解決が食い違う不整合を生むため、既存のIsRaycastCandidateは
  維持し、Canvas収集/判定ロジックのみをメソッド抽出してRaycastContextから再利用する形にした。
  既存のRaycastUIもRaycastContext委譲にし、マージ規則の重複を除去した。

RaycastGridAnnotatorTests.cs(30テスト)を移植し、各テストにWHATコメントを付与。
uloop compileでエラー・warning 0件を確認、既存のUiRaycastHelper利用箇所
(MouseUiDragTargetResolverTests / MouseUiPointerTargetResolverTests / SimulateMouseUiTests /
SimulateMouseUiInputSystemTests / InputReplayVerificationE2ETests)が全てgreenのままであることを
確認し、リファクタによる回帰がないことを検証した。
@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@hatayama, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 5 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0b278d2c-154a-44c4-8ca6-59d71b8b7bfe

📥 Commits

Reviewing files that changed from the base of the PR and between 5352e00 and 5e15af7.

⛔ Files ignored due to path filters (10)
  • Assets/Tests/Editor/RaycastGridAnnotatorTests.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastGridAnnotator.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastHitClusterer.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastLayerMaskResolver.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastSampleOutlineBuilder.cs.meta is excluded by none and included by none
  • Packages/src/Editor/FirstPartyTools/Screenshot/UnityCLILoop.FirstPartyTools.Screenshot.Editor.asmdef is excluded by none and included by none
  • Packages/src/Editor/ToolContracts/RaycastGridPointInfo.cs.meta is excluded by none and included by none
  • Packages/src/Editor/ToolContracts/RaycastLayerSummaryInfo.cs.meta is excluded by none and included by none
  • Packages/src/Editor/ToolContracts/RaycastOutlineSegment.cs.meta is excluded by none and included by none
📒 Files selected for processing (11)
  • Assets/Tests/Editor/RaycastGridAnnotatorTests.cs
  • Packages/src/Editor/FirstPartyTools/Common/GameView/AssemblyInfo.cs
  • Packages/src/Editor/FirstPartyTools/Common/MouseUi/UiRaycastHelper.cs
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastGridAnnotator.cs
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastHitClusterer.cs
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastLayerMaskResolver.cs
  • Packages/src/Editor/FirstPartyTools/Screenshot/RaycastAnnotation/RaycastSampleOutlineBuilder.cs
  • Packages/src/Editor/ToolContracts/RaycastGridPointInfo.cs
  • Packages/src/Editor/ToolContracts/RaycastLayerSummaryInfo.cs
  • Packages/src/Editor/ToolContracts/RaycastOutlineSegment.cs
  • Packages/src/Editor/ToolContracts/UIElementInfo.cs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/raycast-grid-annotation

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 ac381ba into v3-beta Jul 9, 2026
10 checks passed
@hatayama
hatayama deleted the feat/raycast-grid-annotation branch July 9, 2026 10:00
RyanXie123 pushed a commit to RyanXie123/unity-cli-loop that referenced this pull request Sep 22, 2026
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