Agent SkillsBesty0728/Unity-Skills › unity-material

unity-material

GitHub

用于在Unity中编辑材质和Shader属性,支持Built-in/URP/HDRP管线。提供创建、赋值、修改颜色/纹理/参数及批量操作技能,涵盖对象与资产路径自动识别及防幻觉护栏。

SkillsForUnity/unity-skills~/skills/material/SKILL.md Besty0728/Unity-Skills

Trigger Scenarios

调整物体外观 修改材质参数 切换Shader

Install

npx skills add Besty0728/Unity-Skills --skill unity-material -g -y
More Options

Non-standard path

npx skills add https://github.com/Besty0728/Unity-Skills/tree/main/SkillsForUnity/unity-skills~/skills/material -g -y

Use without installing

npx skills use Besty0728/Unity-Skills@unity-material

指定 Agent (Claude Code)

npx skills add Besty0728/Unity-Skills --skill unity-material -a claude-code -g -y

安装 repo 全部 skill

npx skills add Besty0728/Unity-Skills --all -g -y

预览 repo 内 skill

npx skills add Besty0728/Unity-Skills --list

SKILL.md

Frontmatter
{
    "name": "unity-material",
    "description": "Edit material and shader properties across Built-in\/URP\/HDRP"
}

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.

Triggers

  • Changing how a surface looks
  • Tweaking material parameters
  • Swapping shaders
  • 调整物体外观、修改材质参数、切换 Shader

Unity Material Skills

BATCH-FIRST: Use *_batch skills when operating on 2+ objects/materials.

Operating Mode

  • Approval (default): all mutating skills (material_create, material_create_batch, material_assign, material_assign_batch, material_duplicate, material_set_color / _emission / _texture / _float / _int / _vector / _keyword / _render_queue / _shader / _texture_offset / _texture_scale / _gi_flags, and the *_batch variants) need user grant; grant triggers a single server-side execution that returns the result.
  • Auto / Bypass: those skills execute directly.
  • Query skills (material_get_properties, material_get_keywords) are SkillMode.SemiAuto — they run in all three modes without grant.
  • This module contains no Delete / PlayMode / Reload / high-risk skills (no NeverInSemi); to delete a material asset, call the asset module.

Guardrails

DO NOT (common hallucinations):

  • material_set_metallic / material_set_smoothness do not exist → use material_set_float with propertyName="_Metallic" or "_Glossiness" (Standard) / "_Smoothness" (URP)
  • material_set_color r/g/b/a range is 0–1, not 0–255
  • material_set_property does not exist → use the specific setter: material_set_float, material_set_int, material_set_vector, material_set_color
  • material_get_color does not exist → use material_get_properties (returns all properties including colors)

Routing:

  • For shader changes → material_set_shader (this module)
  • For texture tiling → material_set_texture_scale / material_set_texture_offset
  • Pipeline-specific property names differ: check Render Pipeline Compatibility table in this doc

Object Targeting: Most single-object skills accept name (GameObject name) or path. Behaviour of path:

  • In material_set_* / material_get_* (color/emission/texture/float/int/vector/keyword/shader/render_queue/gi_flags/properties), path may be either a GameObject hierarchy path or a material asset path like Assets/Materials/X.mat — the skill auto-detects (paths starting with Assets/ or ending with .mat are treated as material assets).
  • In material_assign, path is a GameObject hierarchy path only; the material to assign goes in the separate materialPath parameter.

Skills Overview

Single Object Batch Version Use Batch When
material_create material_create_batch Creating 2+ materials
material_assign material_assign_batch Assigning to 2+ objects
material_set_color material_set_colors_batch Setting colors on 2+ objects
material_set_emission material_set_emission_batch Setting emission on 2+ objects

No batch needed:

  • material_set_texture - Set texture
  • material_set_texture_offset/scale - Texture tiling
  • material_set_float/int/vector - Set properties
  • material_set_keyword - Enable/disable shader keywords
  • material_set_render_queue - Set render queue
  • material_set_shader - Change shader
  • material_get_properties/keywords - Query properties
  • material_duplicate - Duplicate material

Skills

material_create

Create a new material (auto-detects render pipeline).

Parameter Type Required Default Description
name string Yes - Material name
shaderName string No auto-detect Shader (auto-detects URP/HDRP/Standard)
savePath string No null Save path (folder or full path)

material_create_batch

Create multiple materials.

Parameter Type Required Default Description
items json string Yes - JSON array of per-item objects (see example below)

Returns: {success, totalItems, successCount, failCount, results: [{success, name, path}]}

unity_skills.call_skill("material_create_batch", items=[
    {"name": "Red", "savePath": "Assets/Materials"},
    {"name": "Blue", "savePath": "Assets/Materials"},
    {"name": "Green", "savePath": "Assets/Materials"}
])

material_assign

Assign material to object's renderer.

Parameter Type Required Description
name string No* GameObject name
instanceId int No* Instance ID
path string No* GameObject hierarchy path
materialPath string Yes Material asset to assign (e.g. Assets/Materials/X.mat)

material_assign_batch

Assign materials to multiple objects.

Parameter Type Required Default Description
items json string Yes - JSON array of per-item objects (see example below)

Returns: {success, totalItems, successCount, failCount, results: [{success, name, materialPath}]}

unity_skills.call_skill("material_assign_batch", items=[
    {"name": "Cube1", "materialPath": "Assets/Materials/Red.mat"},
    {"name": "Cube2", "materialPath": "Assets/Materials/Blue.mat"}
])

material_set_color

Set material color with optional HDR intensity.

Parameter Type Required Default Description
name string No* GameObject name
path string No* Material asset path
r, g, b float No 1 Color (0-1)
a float No 1 Alpha
propertyName string No auto-detect Color property
intensity float No 1.0 HDR intensity (>1 for bloom)

material_set_colors_batch

Set colors on multiple objects. Each item accepts: identifier (name/instanceId/path) + r, g, b, a, optional per-item propertyName.

Parameter Type Required Default Description
items json string Yes - JSON array of `{name
propertyName string No auto-detect Default color property applied to all items unless overridden

Returns: {success, totalItems, successCount, failCount, results: [{success, name}]}

unity_skills.call_skill("material_set_colors_batch", items=[
    {"name": "Cube1", "r": 1, "g": 0, "b": 0},
    {"name": "Cube2", "r": 0, "g": 1, "b": 0},
    {"name": "Cube3", "r": 0, "g": 0, "b": 1}
])

material_set_emission

Set emission color with auto-enable keyword.

Parameter Type Required Default Description
name string No* GameObject name
path string No* Material asset path
r, g, b float No 1 Emission color (0-1)
intensity float No 1.0 HDR intensity (>1 for bloom)
enableEmission bool No true Auto-enable _EMISSION keyword

material_set_emission_batch

Set emission on multiple objects.

Parameter Type Required Default Description
items json string Yes - JSON array of per-item objects (see example below)

Returns: {success, totalItems, successCount, failCount, results: [{success, name}]}

unity_skills.call_skill("material_set_emission_batch", items=[
    {"name": "Neon1", "r": 1, "g": 0, "b": 1, "intensity": 5.0},
    {"name": "Neon2", "r": 0, "g": 1, "b": 1, "intensity": 5.0}
])

material_set_texture

Set material texture.

Parameter Type Required Default Description
name string No* GameObject name
path string No* Material asset path
texturePath string Yes - Texture asset path
propertyName string No auto-detect Texture property

material_set_float

Set a float property on a material.

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path
propertyName string Yes Property name
value float Yes Value

material_set_int

Set an integer property on a material.

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path
propertyName string Yes Property name
value int Yes Value

material_set_keyword

Enable/disable shader keywords.

Parameter Type Required Default Description
name string No* GameObject name
path string No* Material asset path
keyword string Yes - Keyword name
enable bool No true Enable or disable

Common Keywords: _EMISSION, _NORMALMAP, _METALLICGLOSSMAP, _ALPHATEST_ON, _ALPHABLEND_ON

material_get_properties

Get all material properties.

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path

Returns: {success, target, shader, renderQueue, keywords, giFlags, properties: {colors, floats, vectors, textures, integers}}

material_get_keywords

Get all enabled shader keywords on a material.

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path

material_duplicate

Duplicate a material asset.

Parameter Type Required Description
sourcePath string Yes Source material path
newName string Yes Name for the duplicated material
savePath string No Optional folder/path override for the duplicated material

material_set_shader

Change the shader of a material.

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path
shaderName string Yes Shader name

material_set_vector

Set a Vector4 property on a material.

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path
propertyName string Yes Property name
x, y, z, w float Yes Vector components

material_set_texture_offset

Set texture offset (tiling position).

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path
propertyName string No Texture property name
x, y float Yes Offset values

material_set_texture_scale

Set texture scale (tiling).

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path
propertyName string No Texture property name
x, y float Yes Scale values

material_set_render_queue

Set material render queue.

Parameter Type Required Description
name string No* GameObject name
path string No* Material asset path
renderQueue int Yes Render queue value

material_set_gi_flags

Set material global illumination flags.

Parameter Type Required Default Description
name string No* - GameObject name
path string No* - GameObject hierarchy path or material asset path
flags string No RealtimeEmissive GI flags: None / RealtimeEmissive / BakedEmissive / EmissiveIsBlack / AnyEmissive

Example: Efficient Material Setup

import unity_skills

# BAD: 6 API calls
unity_skills.call_skill("material_create", name="Mat1", savePath="Assets/Materials")
unity_skills.call_skill("material_create", name="Mat2", savePath="Assets/Materials")
unity_skills.call_skill("material_set_color", path="Assets/Materials/Mat1.mat", r=1, g=0, b=0)
unity_skills.call_skill("material_set_color", path="Assets/Materials/Mat2.mat", r=0, g=0, b=1)
unity_skills.call_skill("material_assign", name="Cube1", materialPath="Assets/Materials/Mat1.mat")
unity_skills.call_skill("material_assign", name="Cube2", materialPath="Assets/Materials/Mat2.mat")

# GOOD: 3 API calls
unity_skills.call_skill("material_create_batch", items=[
    {"name": "Mat1", "savePath": "Assets/Materials"},
    {"name": "Mat2", "savePath": "Assets/Materials"}
])
unity_skills.call_skill("material_set_colors_batch", items=[
    {"path": "Assets/Materials/Mat1.mat", "r": 1, "g": 0, "b": 0},
    {"path": "Assets/Materials/Mat2.mat", "r": 0, "g": 0, "b": 1}
])
unity_skills.call_skill("material_assign_batch", items=[
    {"name": "Cube1", "materialPath": "Assets/Materials/Mat1.mat"},
    {"name": "Cube2", "materialPath": "Assets/Materials/Mat2.mat"}
])

Render Pipeline Compatibility

Skills auto-detect and adapt to your render pipeline:

Pipeline Default Shader Color Property Texture Property
Built-in Standard _Color _MainTex
URP Universal Render Pipeline/Lit _BaseColor _BaseMap
HDRP HDRP/Lit _BaseColor _BaseColorMap

Best Practices

  1. Save materials as assets for reuse
  2. Use material instances (by name) for runtime changes
  3. Use material assets (by path) for persistent changes
  4. Check shader property names in Unity Inspector
  5. URP/HDRP have different property names than Standard

Exact Signatures

Exact names, parameters, defaults, and returns are defined by GET /skills/schema or unity_skills.get_skill_schema(), not by this file.

Common Errors

Full transport-level codes (COMPILING/RATE_LIMIT etc.) → ../../references/protocol-error-codes.md

Error Trigger Fix
TARGET_NOT_FOUND The material asset, GameObject/renderer, shader, texture, or property could not be found (e.g., Material asset not found, No Renderer component found, Shader not found). Verify the asset path with asset_find, the object with gameobject_find, or inspect available properties with material_get_properties.
MISSING_PARAM A required parameter is missing, such as materialPath, sourcePath, texturePath, propertyName, keyword, or shaderName. Supply the parameter named in the error and retry; use mode=dryRun for the full schema.
SEMANTIC_INVALID An invalid value was supplied, such as an unrecognized GI flag, an invalid asset path, or a property name the shader does not use. Correct the value using the allowed range/enum/path convention described in the error.

Version History

  • 5ee8388 Current 2026-08-17 04:11

    精简根SKILL.md至6.2KB,将协议细节移至参考文件;新增SKILL_GUIDE.md指导模式文档;更新模块描述为英文并添加常见错误章节;版本锚点升级至2.6.0。

  • 25d511e 2026-08-13 09:14

    压缩描述至约5191字符,并将路由说明移至Triggers部分

  • e49379b 2026-07-31 06:54

    版本升级至2.4.0

  • ec9f870 2026-07-05 14:40

Same Skill Collection

SkillsForUnity/unity-skills~/skills/addressables-design/SKILL.md
SkillsForUnity/unity-skills~/skills/adr/SKILL.md
SkillsForUnity/unity-skills~/skills/animator/SKILL.md
SkillsForUnity/unity-skills~/skills/behavior/SKILL.md
SkillsForUnity/unity-skills~/skills/blueprints/SKILL.md
SkillsForUnity/unity-skills~/skills/event/SKILL.md
SkillsForUnity/unity-skills~/skills/graphics/SKILL.md
SkillsForUnity/unity-skills~/skills/history/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-component/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-gameobject/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-material/SKILL.md
SkillsForUnity/unity-skills~/skills/manual-scene/SKILL.md
SkillsForUnity/unity-skills~/skills/netcode-design/SKILL.md
SkillsForUnity/unity-skills~/skills/netcode/SKILL.md
SkillsForUnity/unity-skills~/skills/perception/SKILL.md
SkillsForUnity/unity-skills~/skills/pico-design/SKILL.md
SkillsForUnity/unity-skills~/skills/primetween/SKILL.md
SkillsForUnity/unity-skills~/skills/probuilder/SKILL.md
SkillsForUnity/unity-skills~/skills/profiler/SKILL.md
SkillsForUnity/unity-skills~/skills/project-scout/SKILL.md
SkillsForUnity/unity-skills~/skills/sample/SKILL.md
SkillsForUnity/unity-skills~/skills/shadergraph-design/SKILL.md
SkillsForUnity/unity-skills~/skills/SKILL.md
SkillsForUnity/unity-skills~/skills/smart/SKILL.md
SkillsForUnity/unity-skills~/skills/unity-cli/SKILL.md
SkillsForUnity/unity-skills~/skills/yaml-editing/SKILL.md
SkillsForUnity/unity-skills~/SKILL.md
SkillsForUnity/unity-skills~/skills/architecture/SKILL.md
SkillsForUnity/unity-skills~/skills/asmdef/SKILL.md
SkillsForUnity/unity-skills~/skills/asset/SKILL.md
SkillsForUnity/unity-skills~/skills/async/SKILL.md
SkillsForUnity/unity-skills~/skills/batch/SKILL.md
SkillsForUnity/unity-skills~/skills/bookmark/SKILL.md
SkillsForUnity/unity-skills~/skills/camera/SKILL.md
SkillsForUnity/unity-skills~/skills/cinemachine/SKILL.md
SkillsForUnity/unity-skills~/skills/cleaner/SKILL.md
SkillsForUnity/unity-skills~/skills/component/SKILL.md
SkillsForUnity/unity-skills~/skills/console/SKILL.md
SkillsForUnity/unity-skills~/skills/debug/SKILL.md
SkillsForUnity/unity-skills~/skills/decal/SKILL.md
SkillsForUnity/unity-skills~/skills/dotween-design/SKILL.md
SkillsForUnity/unity-skills~/skills/dotween/SKILL.md
SkillsForUnity/unity-skills~/skills/editor/SKILL.md
SkillsForUnity/unity-skills~/skills/gameobject/SKILL.md
SkillsForUnity/unity-skills~/skills/hybridclr/SKILL.md
SkillsForUnity/unity-skills~/skills/importer/SKILL.md
SkillsForUnity/unity-skills~/skills/inspector/SKILL.md
SkillsForUnity/unity-skills~/skills/light/SKILL.md
SkillsForUnity/unity-skills~/skills/navmesh/SKILL.md

Metadata

Files
0
Version
5ee8388
Hash
c7fd2931
Indexed
2026-07-05 14:40

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-17 18:55
浙ICP备14020137号-1 $Гость$