unity-light
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseUnity Light Skills
Unity灯光技能
BATCH-FIRST: Useskills when operating on 2+ lights.*_batch
优先批量操作:当操作2个及以上灯光时,请使用技能。*_batch
Guardrails
约束规则
Mode: Full-Auto required
DO NOT (common hallucinations):
- does not exist → use
light_add(creates a new light GameObject)light_create - /
light_set_colordo not exist → uselight_set_intensity(sets color, intensity, range, shadows together)light_set_properties - does not exist → use
light_deleteon the light's GameObjectgameobject_delete - does not exist → use
light_set_shadowwithlight_set_propertiesparameter ("none"/"hard"/"soft")shadows
Routing:
- For lightmap baking settings → (this module)
light_get_lightmap_settings - For reflection probes → (this module)
light_add_reflection_probe - For light probe groups → (this module)
light_add_probe_group
Object Targeting: All single-object skills accept(string) andname(int, preferred). Provide at least one.instanceId(hierarchy path) is also accepted where noted.path
模式:需使用全自动模式
禁止操作(常见错误):
- 不存在 → 使用
light_add(创建新的灯光GameObject)light_create - /
light_set_color不存在 → 使用light_set_intensity(同时设置颜色、强度、范围、阴影)light_set_properties - 不存在 → 对灯光的GameObject使用
light_deletegameobject_delete - 不存在 → 使用带
light_set_shadow参数的shadows(参数值为"none"/"hard"/"soft")light_set_properties
路由规则:
- 关于光照贴图烘焙设置 → 使用(本模块)
light_get_lightmap_settings - 关于反射探针 → 使用(本模块)
light_add_reflection_probe - 关于光照探针组 → 使用(本模块)
light_add_probe_group
对象定位:所有单对象技能支持(字符串)和name(整数,推荐使用)。至少提供其中一个。部分场景也支持instanceId(层级路径)。path
Skills Overview
技能概览
| Single Object | Batch Version | Use Batch When |
|---|---|---|
| | Configuring 2+ lights |
| | Toggling 2+ lights |
No batch needed:
- - Create a light
light_create - - Get light information
light_get_info - - Find all lights (returns list)
light_find_all
| 单对象技能 | 批量版本 | 使用批量场景 |
|---|---|---|
| | 配置2个及以上灯光 |
| | 切换2个及以上灯光的启用状态 |
无需批量操作的技能:
- - 创建灯光
light_create - - 获取灯光信息
light_get_info - - 查找所有灯光(返回列表)
light_find_all
Light Types
灯光类型
| Type | Description | Use Case |
|---|---|---|
| Parallel rays, no position | Sun, moon |
| Omnidirectional from a point | Torches, bulbs |
| Cone-shaped beam | Flashlights, spotlights |
| Rectangle/disc (baked only) | Windows, soft lights |
| 类型 | 描述 | 使用场景 |
|---|---|---|
| 平行光线,无位置限制 | 太阳、月亮 |
| 从点向全方向发射光线 | 火把、灯泡 |
| 锥形光束 | 手电筒、聚光灯 |
| 矩形/圆盘形(仅支持烘焙) | 窗户、柔和光源 |
Skills
技能详情
light_create
light_create
Create a new light.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | No | "New Light" | Light name |
| string | No | "Point" | Directional/Point/Spot/Area |
| float | No | 0,3,0 | Position |
| float | No | 1,1,1 | Color (0-1) |
| float | No | 1 | Light intensity |
| float | No | 10 | Range (Point/Spot) |
| float | No | 30 | Cone angle (Spot only) |
| string | No | "soft" | none/hard/soft |
Returns:
{success, name, instanceId, lightType, position, color, intensity, shadows}创建新灯光。
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 否 | "New Light" | 灯光名称 |
| string | 否 | "Point" | Directional/Point/Spot/Area |
| float | 否 | 0,3,0 | 位置坐标 |
| float | 否 | 1,1,1 | 颜色(取值0-1) |
| float | 否 | 1 | 灯光强度 |
| float | 否 | 10 | 光照范围(Point/Spot类型适用) |
| float | 否 | 30 | 锥形角度(仅Spot类型适用) |
| string | 否 | "soft" | none/hard/soft |
返回值:
{success, name, instanceId, lightType, position, color, intensity, shadows}light_set_properties
light_set_properties
Configure light properties.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | No* | Light object name |
| int | No* | Instance ID (preferred) |
| float | No | Color (0-1) |
| float | No | Light intensity |
| float | No | Range (Point/Spot) |
| string | No | none/hard/soft |
配置灯光属性。
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 否* | 灯光对象名称 |
| int | 否* | 实例ID(推荐使用) |
| float | 否 | 颜色(取值0-1) |
| float | 否 | 灯光强度 |
| float | 否 | 光照范围(Point/Spot类型适用) |
| string | 否 | none/hard/soft |
light_set_properties_batch
light_set_properties_batch
Configure multiple lights. Each item accepts: // (identifier) + , , , , , (all optional).
nameinstanceIdpathrgbintensityrangeshadowsReturns:
{success, totalItems, successCount, failCount, results: [{success, name}]}python
unity_skills.call_skill("light_set_properties_batch", items=[
{"name": "Light1", "intensity": 2.0, "r": 1, "g": 0.9, "b": 0.8},
{"instanceId": 12345, "intensity": 1.5, "shadows": "soft"},
{"name": "Light3", "intensity": 2.0}
])配置多个灯光。每个条目可包含://(标识符) + , , , , , (均为可选参数)。
nameinstanceIdpathrgbintensityrangeshadows返回值:
{success, totalItems, successCount, failCount, results: [{success, name}]}python
unity_skills.call_skill("light_set_properties_batch", items=[
{"name": "Light1", "intensity": 2.0, "r": 1, "g": 0.9, "b": 0.8},
{"instanceId": 12345, "intensity": 1.5, "shadows": "soft"},
{"name": "Light3", "intensity": 2.0}
])light_set_enabled
light_set_enabled
Enable or disable a light.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | No* | Light object name |
| int | No* | Instance ID |
| bool | Yes | Enable state |
启用或禁用灯光。
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 否* | 灯光对象名称 |
| int | 否* | 实例ID |
| bool | 是 | 启用状态 |
light_set_enabled_batch
light_set_enabled_batch
Enable or disable multiple lights.
Returns:
{success, totalItems, successCount, failCount, results: [{success, name, enabled}]}python
unity_skills.call_skill("light_set_enabled_batch", items=[
{"name": "Torch1", "enabled": False},
{"name": "Torch2", "enabled": False},
{"name": "Torch3", "enabled": False}
])启用或禁用多个灯光。
返回值:
{success, totalItems, successCount, failCount, results: [{success, name, enabled}]}python
unity_skills.call_skill("light_set_enabled_batch", items=[
{"name": "Torch1", "enabled": False},
{"name": "Torch2", "enabled": False},
{"name": "Torch3", "enabled": False}
])light_get_info
light_get_info
Get detailed light information.
| Parameter | Type | Required | Description |
|---|---|---|---|
| string | No* | Light object name |
| int | No* | Instance ID |
Returns:
{name, instanceId, path, lightType, color, intensity, range, spotAngle, shadows, enabled}获取灯光详细信息。
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
| string | 否* | 灯光对象名称 |
| int | 否* | 实例ID |
返回值:
{name, instanceId, path, lightType, color, intensity, range, spotAngle, shadows, enabled}light_find_all
light_find_all
Find all lights in scene.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | No | null | Filter by type |
| int | No | 50 | Max results |
Returns:
{count, lights: [{name, instanceId, path, lightType, intensity, enabled}]}查找场景中所有灯光。
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 否 | null | 按类型过滤 |
| int | 否 | 50 | 最大返回数量 |
返回值:
{count, lights: [{name, instanceId, path, lightType, intensity, enabled}]}light_add_probe_group
light_add_probe_grouplight_add_probe_group
light_add_probe_groupAdd a Light Probe Group to a GameObject. Optional grid layout: gridX/gridY/gridZ (count per axis), spacingX/spacingY/spacingZ (meters between probes).
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | No | null | GameObject name |
| int | No | 0 | Instance ID |
| string | No | null | Hierarchy path |
| int | No | 0 | Probe count on X axis |
| int | No | 0 | Probe count on Y axis |
| int | No | 0 | Probe count on Z axis |
| float | No | 2 | Meters between probes on X |
| float | No | 1.5 | Meters between probes on Y |
| float | No | 2 | Meters between probes on Z |
Returns:
{ success, gameObject, probeCount, existed, hasGrid }为GameObject添加光照探针组。可选网格布局:gridX/gridY/gridZ(各轴探针数量),spacingX/spacingY/spacingZ(探针间距,单位米)。
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 否 | null | GameObject名称 |
| int | 否 | 0 | 实例ID |
| string | 否 | null | 层级路径 |
| int | 否 | 0 | X轴探针数量 |
| int | 否 | 0 | Y轴探针数量 |
| int | 否 | 0 | Z轴探针数量 |
| float | 否 | 2 | X轴探针间距(米) |
| float | 否 | 1.5 | Y轴探针间距(米) |
| float | 否 | 2 | Z轴探针间距(米) |
返回值:
{ success, gameObject, probeCount, existed, hasGrid }light_add_reflection_probe
light_add_reflection_probelight_add_reflection_probe
light_add_reflection_probeCreate a Reflection Probe at a position.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| string | No | "ReflectionProbe" | Probe name |
| float | No | 0,1,0 | Position |
| float | No | 10,10,10 | Probe box size |
| int | No | 256 | Cubemap resolution |
Returns:
{ success, name, instanceId, resolution, size }在指定位置创建反射探针。
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
| string | 否 | "ReflectionProbe" | 探针名称 |
| float | 否 | 0,1,0 | 位置坐标 |
| float | 否 | 10,10,10 | 探针盒尺寸 |
| int | 否 | 256 | 立方体贴图分辨率 |
返回值:
{ success, name, instanceId, resolution, size }light_get_lightmap_settings
light_get_lightmap_settingslight_get_lightmap_settings
light_get_lightmap_settingsGet Lightmap baking settings.
No parameters.
Returns:
{ success, bakedGI, realtimeGI, lightmapSize, lightmapPadding, isRunning, lightmapCount }获取光照贴图烘焙设置。
无参数。
返回值:
{ success, bakedGI, realtimeGI, lightmapSize, lightmapPadding, isRunning, lightmapCount }Example: Efficient Lighting Setup
示例:高效灯光设置
python
import unity_skillspython
import unity_skillsBAD: 4 API calls
不推荐:4次API调用
unity_skills.call_skill("light_set_properties", name="Light1", intensity=2.0)
unity_skills.call_skill("light_set_properties", name="Light2", intensity=2.0)
unity_skills.call_skill("light_set_properties", name="Light3", intensity=2.0)
unity_skills.call_skill("light_set_properties", name="Light4", intensity=2.0)
unity_skills.call_skill("light_set_properties", name="Light1", intensity=2.0)
unity_skills.call_skill("light_set_properties", name="Light2", intensity=2.0)
unity_skills.call_skill("light_set_properties", name="Light3", intensity=2.0)
unity_skills.call_skill("light_set_properties", name="Light4", intensity=2.0)
GOOD: 1 API call
推荐:1次API调用
unity_skills.call_skill("light_set_properties_batch", items=[
{"name": "Light1", "intensity": 2.0},
{"name": "Light2", "intensity": 2.0},
{"name": "Light3", "intensity": 2.0},
{"name": "Light4", "intensity": 2.0}
])
undefinedunity_skills.call_skill("light_set_properties_batch", items=[
{"name": "Light1", "intensity": 2.0},
{"name": "Light2", "intensity": 2.0},
{"name": "Light3", "intensity": 2.0},
{"name": "Light4", "intensity": 2.0}
])
undefinedMinimal Example
极简示例
python
unity_skills.call_skill("light_create",
name="Sun", lightType="Directional",
r=1, g=0.95, b=0.85, intensity=1.2, shadows="soft"
)python
unity_skills.call_skill("light_create",
name="Sun", lightType="Directional",
r=1, g=0.95, b=0.85, intensity=1.2, shadows="soft"
)Best Practices
最佳实践
- Use Directional light for main scene illumination
- Point lights for localized sources (lamps, fires)
- Spot lights for focused beams (flashlights, stage)
- Limit real-time shadows for performance
- Area lights require baking (not real-time)
- Use intensity > 1 for HDR/bloom effects
- 使用Directional灯光作为场景主光源
- 使用Point灯光作为局部光源(台灯、火焰)
- 使用Spot灯光作为聚焦光束(手电筒、舞台灯)
- 限制实时阴影数量以提升性能
- Area灯光仅支持烘焙(不支持实时渲染)
- 强度大于1时可实现HDR/ bloom效果
Exact Signatures
精确签名
Exact names, parameters, defaults, and returns are defined by or , not by this file.
GET /skills/schemaunity_skills.get_skill_schema()技能的精确名称、参数、默认值及返回值由或定义,而非本文档。
GET /skills/schemaunity_skills.get_skill_schema()