unity-camera

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Before calling any skill in this module: if you are about to call a skill with parameters guessed from its name or description, STOP — read this file (or fetch its schema via
GET /skills/recommend?includeSchema=true
) first. If you already have the parameter definitions from recommend/schema, you may proceed straight to dryRun.
调用本模块中的任何技能之前:如果你打算根据技能名称或描述猜测参数来调用技能,请停止——先阅读本文档(或通过
GET /skills/recommend?includeSchema=true
获取其schema)。如果你已经从推荐/schema中获取了参数定义,可以直接进行dryRun。

Triggers

触发场景

  • Framing the Scene View
  • Creating or adjusting cameras
  • Tweaking FOV or clipping planes
  • 取景 Scene View、创建或调整相机、修改 FOV 或裁剪面
  • 调整Scene View取景
  • 创建或调整相机
  • 修改FOV或裁剪面
  • 取景Scene View、创建或调整相机、修改FOV或裁剪面

Camera Skills

相机技能

Control the Scene View camera and Game Cameras (creation, transform, properties, screenshot, culling, orthographic toggle).
控制Scene View相机和Game Camera(创建、变换、属性、截图、剔除、正交模式切换)。

Operating Mode

操作模式

  • Approval (default): mutating skills (
    camera_set_transform
    ,
    camera_create
    ,
    camera_set_properties
    ,
    camera_set_culling_mask
    ,
    camera_screenshot
    ,
    camera_sceneview_screenshot
    ,
    camera_set_orthographic
    ,
    camera_align_view_to_object
    ,
    camera_look_at
    ) need user grant; grant triggers a single server-side execution that returns the result.
  • Auto / Bypass: those skills execute directly.
  • Query skills (
    camera_get_info
    ,
    camera_get_properties
    ,
    camera_list
    ) are
    SkillMode.SemiAuto
    — they run in all three modes without grant.
  • This module contains no Delete / PlayMode / Reload / high-risk skills (no NeverInSemi).
  • 审批模式(默认):变更类技能(
    camera_set_transform
    ,
    camera_create
    ,
    camera_set_properties
    ,
    camera_set_culling_mask
    ,
    camera_screenshot
    ,
    camera_sceneview_screenshot
    ,
    camera_set_orthographic
    ,
    camera_align_view_to_object
    ,
    camera_look_at
    )需要用户授权;授权后触发一次服务器端执行并返回结果。
  • 自动/绕过模式:这些技能直接执行。
  • 查询类技能(
    camera_get_info
    ,
    camera_get_properties
    ,
    camera_list
    )为
    SkillMode.SemiAuto
    ——它们在三种模式下都无需授权即可运行。
  • 本模块不包含删除/播放模式/重载/高风险技能(无NeverInSemi类型)。

Guardrails

注意事项

DO NOT (common hallucinations):
  • camera_move
    /
    camera_rotate
    do not exist → use
    camera_set_transform
    (Scene View) or
    gameobject_set_transform
    (Game Camera)
  • camera_set_fov
    does not exist → use
    camera_set_properties
    with
    fieldOfView
    parameter
  • camera_*
    skills control two different cameras:
    camera_set_transform
    /
    camera_look_at
    /
    camera_align_view_to_object
    control the Scene View camera;
    camera_create
    /
    camera_set_properties
    /
    camera_screenshot
    control Game Cameras
  • camera_delete
    does not exist → use
    gameobject_delete
    on the camera GameObject
Routing:
  • For Cinemachine virtual cameras → use
    cinemachine
    module
  • For Game Camera component properties →
    camera_set_properties
    /
    camera_get_properties
    (this module)
  • For screenshots → three options:
    scene_screenshot
    (scene module) = the Game View final composite (all cameras + UI; Play mode = live runtime frame);
    camera_screenshot
    (this module) = a single Game Camera off-screen render;
    camera_sceneview_screenshot
    (this module) = the editor Scene View (developer viewport, incl. grid/gizmos)
请勿(常见误区):
  • camera_move
    /
    camera_rotate
    不存在 → 使用
    camera_set_transform
    (Scene View相机)或
    gameobject_set_transform
    (Game Camera)
  • camera_set_fov
    不存在 → 使用
    camera_set_properties
    并传入
    fieldOfView
    参数
  • camera_*
    技能控制两种不同的相机:
    camera_set_transform
    /
    camera_look_at
    /
    camera_align_view_to_object
    控制Scene View相机;
    camera_create
    /
    camera_set_properties
    /
    camera_screenshot
    控制Game Camera
  • camera_delete
    不存在 → 对相机GameObject使用
    gameobject_delete
路由规则:
  • 对于Cinemachine虚拟相机 → 使用
    cinemachine
    模块
  • 对于Game Camera组件属性 →
    camera_set_properties
    /
    camera_get_properties
    (本模块)
  • 对于截图 → 三种选项:
    scene_screenshot
    (scene模块)= Game View最终合成画面(所有相机+UI;播放模式=实时运行帧);
    camera_screenshot
    (本模块)= 单个Game Camera的离屏渲染画面;
    camera_sceneview_screenshot
    (本模块)= 编辑器Scene View画面(开发者视口,包含网格/gizmos)

Skills

技能列表

camera_align_view_to_object

camera_align_view_to_object

Align Scene View camera to look at an object. Parameters:
  • name
    (string, optional): Target GameObject name.
  • instanceId
    (int, optional): Target GameObject instance ID.
  • path
    (string, optional): Target GameObject hierarchy path.
将Scene View相机对齐以看向目标物体。 参数:
  • name
    (字符串,可选):目标GameObject名称。
  • instanceId
    (整数,可选):目标GameObject实例ID。
  • path
    (字符串,可选):目标GameObject层级路径。

camera_get_info

camera_get_info

Get the editor Scene View viewport camera's position and rotation — the developer's viewport, not a Camera component in the scene. It takes no target parameters for exactly that reason. For a Game Camera's state use
camera_get_properties
(or
camera_list
to find one); if you just created a camera with
camera_create
and want to confirm its transform,
camera_get_info
will not show it. Parameters: None.
获取编辑器Scene View视口相机的位置和旋转信息——即开发者的视口,并非场景中的Camera组件。正因如此,它不需要目标参数。如需获取Game Camera的状态,请使用
camera_get_properties
(或通过
camera_list
查找);如果你刚用
camera_create
创建了一个相机并想确认其变换信息,
camera_get_info
无法显示该内容。 参数:无。

camera_set_transform

camera_set_transform

Set Scene View camera position/rotation manually. Parameters:
  • posX
    ,
    posY
    ,
    posZ
    (float): Position.
  • rotX
    ,
    rotY
    ,
    rotZ
    (float): Rotation (Euler).
  • size
    (float, optional): Orthographic size or pivot distance (default 5).
  • instant
    (bool, optional): Move instantly (default true).
手动设置Scene View相机的位置/旋转。 参数:
  • posX
    ,
    posY
    ,
    posZ
    (浮点数):位置坐标。
  • rotX
    ,
    rotY
    ,
    rotZ
    (浮点数):旋转角度(欧拉角)。
  • size
    (浮点数,可选):正交大小或枢轴距离(默认值为5)。
  • instant
    (布尔值,可选):是否立即移动(默认值为true)。

camera_look_at

camera_look_at

Focus Scene View camera on a world-space point. Parameters:
  • x
    ,
    y
    ,
    z
    (float): Target point.
  • Does not support
    targetName
    or GameObject lookup. For object focus, use
    camera_align_view_to_object
    .
将Scene View相机聚焦到世界空间中的某个点。 参数:
  • x
    ,
    y
    ,
    z
    (浮点数):目标点坐标。
  • 不支持
    targetName
    或GameObject查找。如需聚焦物体,请使用
    camera_align_view_to_object
    。

camera_create

camera_create

Create a new Game Camera.
ParameterTypeRequiredDefaultDescription
namestringNo"New Camera"Name of the new camera GameObject
xfloatNo0Position X
yfloatNo1Position Y
zfloatNo-10Position Z
addAudioListenerboolNofalseAlso attach an
AudioListener
component
Returns:
{ success, name, instanceId }
创建一个新的Game Camera。
参数类型必填默认值描述
namestring否"New Camera"新相机GameObject的名称
xfloat否0X轴位置
yfloat否1Y轴位置
zfloat否-10Z轴位置
addAudioListenerbool否false是否同时附加
AudioListener
组件
返回值:
{ success, name, instanceId }

camera_get_properties

camera_get_properties

Get Game Camera properties (supports name/instanceId/path).
ParameterTypeRequiredDefaultDescription
namestringNonullName of the camera GameObject
instanceIdintNo0Instance ID of the camera GameObject
pathstringNonullHierarchy path of the camera GameObject
Returns:
{ success, name, fieldOfView, nearClipPlane, farClipPlane, orthographic, orthographicSize, depth, cullingMask, clearFlags, backgroundColor, rect }
获取Game Camera的属性(支持按名称/实例ID/路径查找)。
参数类型必填默认值描述
namestring否null相机GameObject的名称
instanceIdint否0相机GameObject的实例ID
pathstring否null相机GameObject的层级路径
返回值:
{ success, name, fieldOfView, nearClipPlane, farClipPlane, orthographic, orthographicSize, depth, cullingMask, clearFlags, backgroundColor, rect }

camera_set_properties

camera_set_properties

Set Game Camera properties (FOV, clip planes, clear flags, background color, depth).
ParameterTypeRequiredDefaultDescription
namestringNonullName of the camera GameObject
instanceIdintNo0Instance ID of the camera GameObject
pathstringNonullHierarchy path of the camera GameObject
fieldOfViewfloat?NonullCamera field of view
nearClipPlanefloat?NonullNear clipping plane distance
farClipPlanefloat?NonullFar clipping plane distance
depthfloat?NonullCamera rendering depth
clearFlagsstringNonullClear flags:
Skybox
,
Color
,
SolidColor
,
Depth
,
Nothing
.
Color
and
SolidColor
are two names for the same underlying
CameraClearFlags
value, so both are accepted and the response always echoes it back as
Color
— do not read that as the write having been ignored
bgRfloat?NonullBackground color red component (0-1)
bgGfloat?NonullBackground color green component (0-1)
bgBfloat?NonullBackground color blue component (0-1)
bgAfloat?NonullBackground color alpha (0-1)
Any
bg*
channel you omit keeps the camera's current value, so you can set alpha alone.
Returns:
{ success, name, applied, fieldOfView, nearClipPlane, farClipPlane, orthographic, orthographicSize, depth, cullingMask, clearFlags, backgroundColor, rect }
— the response echoes the camera's state after the write, and
applied
lists which parameters were actually changed, named exactly as you passed them (the background channels appear individually as
bgR
,
bgG
,
bgB
,
bgA
, not lumped under
backgroundColor
), so a parameter absent from
applied
was not supplied. That echo is your verification: a second
camera_get_properties
call is redundant. An unparseable
clearFlags
rejects the whole call with
SEMANTIC_INVALID
+
validValues
before anything is applied, so the numeric parameters in the same call are never half-written.
设置Game Camera的属性(FOV、裁剪面、清除标志、背景颜色、深度)。
参数类型必填默认值描述
namestring否null相机GameObject的名称
instanceIdint否0相机GameObject的实例ID
pathstring否null相机GameObject的层级路径
fieldOfViewfloat?否null相机视野
nearClipPlanefloat?否null近裁剪面距离
farClipPlanefloat?否null远裁剪面距离
depthfloat?否null相机渲染深度
clearFlagsstring否null清除标志:
Skybox
,
Color
,
SolidColor
,
Depth
,
Nothing
。
Color
和
SolidColor
是同一底层
CameraClearFlags
值的两个名称,因此两者都被接受,且响应始终以
Color
返回——请勿将此视为写入操作被忽略
bgRfloat?否null背景颜色红色分量(0-1)
bgGfloat?否null背景颜色绿色分量(0-1)
bgBfloat?否null背景颜色蓝色分量(0-1)
bgAfloat?否null背景颜色透明度(0-1)
任何你省略的
bg*
通道将保留相机当前的值,因此你可以单独设置透明度。
返回值:
{ success, name, applied, fieldOfView, nearClipPlane, farClipPlane, orthographic, orthographicSize, depth, cullingMask, clearFlags, backgroundColor, rect }
——响应会返回写入之后的相机状态,
applied
列表会显示实际被修改的参数,名称与你传入的完全一致(背景通道会单独显示为
bgR
,
bgG
,
bgB
,
bgA
,而非归在
backgroundColor
下),因此未出现在
applied
中的参数即为未提供的参数。该返回值可作为验证依据:无需再次调用
camera_get_properties
。如果
clearFlags
无法解析,整个调用会被拒绝并返回
SEMANTIC_INVALID
+
validValues
,且不会应用任何参数,因此同一调用中的数值参数不会被半写入。

camera_set_culling_mask

camera_set_culling_mask

Set Game Camera culling mask by layer names (comma-separated).
ParameterTypeRequiredDefaultDescription
layerNamesstringYes-Comma-separated layer names
namestringNonullName of the camera GameObject
instanceIdintNo0Instance ID of the camera GameObject
pathstringNonullHierarchy path of the camera GameObject
Returns:
{ success, cullingMask }
按层名称(逗号分隔)设置Game Camera的剔除遮罩。
参数类型必填默认值描述
layerNamesstring是-逗号分隔的层名称
namestring否null相机GameObject的名称
instanceIdint否0相机GameObject的实例ID
pathstring否null相机GameObject的层级路径
返回值:
{ success, cullingMask }

camera_screenshot

camera_screenshot

Capture a screenshot from a Game Camera to file.
ParameterTypeRequiredDefaultDescription
savePathstringNo"Assets/screenshot.png"File path to save the screenshot
widthintNo1920Screenshot width in pixels
heightintNo1080Screenshot height in pixels
namestringNonullName of the camera GameObject
instanceIdintNo0Instance ID of the camera GameObject
pathstringNonullHierarchy path of the camera GameObject
returnImageboolNofalseAlso return the PNG as base64 in the response (
imageBase64
), for clients without filesystem access
maxDimensionintNo1280Only used when
returnImage=true
; downscales the returned image (not the saved file) so its longer edge is ≤ this value. Clamped to 256–4096
Returns:
{ success, path, width, height }
, plus
{ imageBase64, imageWidth, imageHeight, imageBytes }
when
returnImage=true
. If the base64 payload would exceed 8MB, the skill returns an error asking for a smaller
maxDimension
— the file at
path
is still saved.
捕获Game Camera的画面并保存到文件。
参数类型必填默认值描述
savePathstring否"Assets/screenshot.png"截图保存路径
widthint否1920截图宽度(像素)
heightint否1080截图高度(像素)
namestring否null相机GameObject的名称
instanceIdint否0相机GameObject的实例ID
pathstring否null相机GameObject的层级路径
returnImagebool否false是否同时在响应中返回PNG格式的base64编码图片(
imageBase64
),供无文件系统访问权限的客户端使用
maxDimensionint否1280仅当
returnImage=true
时生效;缩小返回的图片(不影响保存的文件),使其长边≤该值。取值范围为256–4096
返回值:
{ success, path, width, height }
,当
returnImage=true
时额外返回
{ imageBase64, imageWidth, imageHeight, imageBytes }
。如果base64负载超过8MB,技能会返回错误并要求设置更小的
maxDimension
——但
path
中的文件仍会被保存。

camera_sceneview_screenshot

camera_sceneview_screenshot

Capture the editor Scene View (the developer's editing viewport — can overlook the whole scene incl. off-camera objects). Distinct from
scene_screenshot
(Game View / player camera) and
camera_screenshot
(one Game Camera). By default captures the full Scene View incl. grid/gizmos/selection (on-screen read); auto-falls back to a clean offscreen render if the editor build lacks the internal API. The Scene View window must be open and visible for the overlay capture.
ParameterTypeRequiredDefaultDescription
filenamestringNo"sceneview.png"Bare filename only (no path separators); saved under
Assets/Screenshots/
includeOverlaysboolNotrueTrue = full Scene View with grid/gizmos/selection (falls back to a clean render if unsupported); false = clean offscreen scene render only
returnImageboolNofalseAlso return the PNG as base64 in the response (
imageBase64
), for clients without filesystem access
maxDimensionintNo1280Only used when
returnImage=true
; downscales the returned image (not the saved file) so its longer edge is ≤ this value. Clamped to 256–4096
Returns:
{ success, path, width, height, mode, note }
—
mode
is
"screen_with_overlays"
or
"offscreen_clean"
— plus
{ imageBase64, imageWidth, imageHeight, imageBytes }
when
returnImage=true
. If the base64 payload would exceed 8MB, the skill returns an error asking for a smaller
maxDimension
— the file at
path
is still saved.
returnImage usage tip: a local agent that can read files (e.g. Claude Code against a local Unity Editor) should generally omit
returnImage
and just read the PNG at
path
— it's cheaper on tokens. Use
returnImage=true
for remote/MCP clients that have no filesystem access to the Unity project.
捕获编辑器Scene View画面(即开发者的编辑视口——可俯瞰整个场景,包括相机视野外的物体)。与
scene_screenshot
(Game View/玩家相机)和
camera_screenshot
(单个Game Camera)不同。默认捕获完整的Scene View画面,包括网格/gizmos/选择框(屏幕读取);如果编辑器版本缺少内部API,会自动回退到纯净的离屏渲染。进行叠加捕获时,Scene View窗口必须处于打开且可见状态。
参数类型必填默认值描述
filenamestring否"sceneview.png"仅文件名(无路径分隔符);保存到
Assets/Screenshots/
目录下
includeOverlaysbool否truetrue = 包含网格/gizmos/选择框的完整Scene View画面(如果不支持则回退到纯净渲染);false = 仅纯净的离屏场景渲染画面
returnImagebool否false是否同时在响应中返回PNG格式的base64编码图片(
imageBase64
),供无文件系统访问权限的客户端使用
maxDimensionint否1280仅当
returnImage=true
时生效;缩小返回的图片(不影响保存的文件),使其长边≤该值。取值范围为256–4096
返回值:
{ success, path, width, height, mode, note }
——
mode
为
"screen_with_overlays"
或
"offscreen_clean"
——当
returnImage=true
时额外返回
{ imageBase64, imageWidth, imageHeight, imageBytes }
。如果base64负载超过8MB,技能会返回错误并要求设置更小的
maxDimension
——但
path
中的文件仍会被保存。
returnImage使用提示:可以读取文件的本地代理(例如连接本地Unity Editor的Claude Code)通常应省略
returnImage
,直接读取
path
下的PNG文件——这样更节省token。对于无法访问Unity项目文件系统的远程/MCP客户端,请使用
returnImage=true
。

camera_set_orthographic

camera_set_orthographic

Switch Game Camera between orthographic and perspective mode.
ParameterTypeRequiredDefaultDescription
orthographicboolYes-True for orthographic, false for perspective
orthographicSizefloat?NonullOrthographic size (only applies in orthographic mode)
namestringNonullName of the camera GameObject
instanceIdintNo0Instance ID of the camera GameObject
pathstringNonullHierarchy path of the camera GameObject
Returns:
{ success, orthographic, orthographicSize }
切换Game Camera的正交/透视模式。
参数类型必填默认值描述
orthographicbool是-true为正交模式,false为透视模式
orthographicSizefloat?否null正交大小(仅在正交模式下生效)
namestring否null相机GameObject的名称
instanceIdint否0相机GameObject的实例ID
pathstring否null相机GameObject的层级路径
返回值:
{ success, orthographic, orthographicSize }

camera_list

camera_list

List all cameras in the scene.
ParameterTypeRequiredDefaultDescription
Returns:
{ count, cameras: [{ name, instanceId, path, depth, orthographic, enabled }] }

列出场景中的所有相机。
参数类型必填默认值描述
返回值:
{ count, cameras: [{ name, instanceId, path, depth, orthographic, enabled }] }

Exact Signatures

精确签名

Exact names, parameters, defaults, and returns are defined by
GET /skills/schema
or
unity_skills.get_skill_schema()
, not by this file.
精确的名称、参数、默认值和返回值由
GET /skills/schema
或
unity_skills.get_skill_schema()
定义,而非本文档。