fix(screenshot): capture full Game view — multi-camera + Screen Space-Overlay UI (#33)#34
Open
travlake wants to merge 1 commit into
Open
Conversation
`screenshot --view game` rendered a single camera into an offscreen RenderTexture (Camera.main, else an arbitrary camera). That cannot reproduce a multi-camera stack, and camera.Render() never includes Screen Space - Overlay UI (overlay canvases composite onto the back buffer after camera render) - so the capture came back black / with the UI missing. Fixes youngwoocho02#33. Game view now captures the actual composited back buffer via ScreenCapture.CaptureScreenshot (every stacked camera + all UI, including overlay), awaited end-of-frame using the router's existing async Task<object> handler support. Completion is detected by the PNG IEND chunk so a partially written file is never returned; the wait is bounded by both frame count and wall-clock and is torn down on domain reload. If no frame renders in time (no Game view, batch mode) it falls back to a depth-ordered multi-camera composite whose response message explicitly warns that Screen Space - Overlay UI is omitted. Scene view behaviour is unchanged. Adds super_size (1-4) for the primary path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
screenshot --view gamereturns a black / UI-less image on projects whose Game view is composited from multiple stacked cameras and/or whose HUD lives on Screen Space - Overlay canvases (#33).Root cause
CaptureGameViewrendered a singlecamera.Render()(Camera.main, else an arbitraryFindObjectOfType<Camera>()) into an offscreenRenderTexture. That cannot reproduce a multi-camera stack, andcamera.Render()never includes Screen Space - Overlay UI — overlay canvases are composited onto the back buffer after camera render. So the capture came back black / with the UI missing.Fix
Capture the actual composited back buffer via
ScreenCapture.CaptureScreenshot(every stacked camera + all UI, including overlay), awaited end-of-frame using the router's existing asyncTask<object>handler support (same pattern asRunTests/ManageEditor).IENDbytes rather thanlength > 0, so a partially written file is never returned (ScreenCapture's write is not atomic).beforeAssemblyReload, so an in-flight capture can never leak theupdatesubscription or hold the command lock indefinitely.camera.Render()compositing assumes the built-in render pipeline.Scene view behaviour is unchanged (single SceneView camera). Adds
super_size(1-4) for the primary path;width/heightcontinue to size the fallback.Verification
Built against the connector in Unity 2021.3.45f2 (built-in pipeline) and exercised end-to-end through the live connector:
screenshot --view gamenow captures the full Game view — multi-camera background and all UI canvases — in both edit mode and play mode, where it previously returned solid black.Fixes #33.