MCPcopy Create free account
hub / github.com/bigdra50/unity-cli / capture

Method capture

unity_cli/api/screenshot.py:17–68  ·  view source on GitHub ↗

Capture a screenshot from GameView, SceneView, or Camera. Args: source: "game" for GameView (async, requires editor focus), "scene" for SceneView, "camera" for Camera.Render (sync, focus-independent) path: Output file path. If

(
        self,
        source: Literal["game", "scene", "camera"] = "game",
        path: str | None = None,
        super_size: int = 1,
        width: int | None = None,
        height: int | None = None,
        camera: str | None = None,
        format: Literal["png", "jpg"] | None = None,
        quality: int | None = None,
    )

Source from the content-addressed store, hash-verified

15 self._conn = conn
16
17 def capture(
18 self,
19 source: Literal["game", "scene", "camera"] = "game",
20 path: str | None = None,
21 super_size: int = 1,
22 width: int | None = None,
23 height: int | None = None,
24 camera: str | None = None,
25 format: Literal["png", "jpg"] | None = None,
26 quality: int | None = None,
27 ) -> dict[str, Any]:
28 """Capture a screenshot from GameView, SceneView, or Camera.
29
30 Args:
31 source: "game" for GameView (async, requires editor focus),
32 "scene" for SceneView,
33 "camera" for Camera.Render (sync, focus-independent)
34 path: Output file path. If not specified, saves to Screenshots/ with timestamp
35 super_size: Resolution multiplier for GameView (1-4). Ignored for scene/camera.
36 width: Image width for camera source (default: 1920)
37 height: Image height for camera source (default: 1080)
38 camera: Camera GameObject name for camera source. Uses Main Camera if not specified.
39 format: Image format - "png" or "jpg" (default: png)
40 quality: JPEG quality 1-100 (default: 75). Only used with jpg format.
41
42 Returns:
43 Dictionary with capture result including:
44 - message: Status message
45 - path: Output file path
46 - source: Capture source ("game", "scene", or "camera")
47 - format: Image format used
48 - width/height: Image dimensions (for scene/camera captures)
49 - camera: Camera name (for camera captures)
50 """
51 params: dict[str, Any] = {
52 "action": "capture",
53 "source": source,
54 "superSize": super_size,
55 }
56 if path is not None:
57 params["path"] = path
58 if width is not None:
59 params["width"] = width
60 if height is not None:
61 params["height"] = height
62 if camera is not None:
63 params["camera"] = camera
64 if format is not None:
65 params["format"] = format
66 if quality is not None:
67 params["quality"] = quality
68 return self._conn.send_request("screenshot", params)
69
70 def burst(
71 self,

Callers 1

_captureFunction · 0.80

Calls 1

send_requestMethod · 0.80

Tested by

no test coverage detected