Agent Skills › Besty0728/Unity-Skills › unity-component

unity-component

GitHub

管理Unity游戏对象组件,支持挂载、移除、复制、开关及读写序列化字段。涵盖单对象与批量操作,处理类型解析、属性命名映射及值编码,包含只读半自动与写入全自动模式,并限制高危删除操作。

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

Trigger Scenarios

挂载或移除组件 在对象间复制组件 开关组件 读写序列化字段

Install

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

Non-standard path

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

Use without installing

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

指定 Agent (Claude Code)

npx skills add Besty0728/Unity-Skills --skill unity-component -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-component",
    "description": "Manage GameObject components"
}

Triggers

  • Attaching or removing components
  • Copying components between objects
  • Toggling components
  • Reading/writing serialized fields
  • 挂载或移除组件、在对象间复制组件、开关组件、读写序列化字段

Unity Component Skills

Add, remove, copy, toggle and edit components. Parameters come from the schema (recommend includeSchema=true or /skills/schema?names=), which notes the non-obvious ones — never from a skill's name. Execution, dryRun and verification rules: root SKILL.md.

Operating Mode

component_list, component_get_methods, component_get_methods_batch, component_get_properties, component_get_serialized_properties are SemiAuto (read-only); every writer is FullAuto. component_remove / component_remove_batch (Operation.Delete) and component_invoke_method* (high risk) are NeverInSemi: MODE_FORBIDDEN under Approval/Auto, run only under Bypass or an Allowlist hit → operating mode.

Shared rules

  • Targets: single-object skills take name, instanceId or path (plus entityId, resolved to the path), matched like GameObjects: an ambiguous fuzzy name returns TARGET_NOT_FOUND with candidates, non-exact matches are listed in resolutionNotes. Batch items take only name / instanceId / path: an entityId item key is ignored (named in warnings), so the item finds no target. component_copy* use source* / target* identifiers.
  • componentType (required): the class name — Rigidbody, BoxCollider, Namespace.ClassName for custom scripts. Unity, UI, TextMeshPro, Cinemachine and Input System namespaces are searched first, then a case-insensitive scan that takes the first matching type; the response's component / fullTypeName show what was resolved.
  • Two naming schemes: component_set_property / component_get_properties use C# member names (mass, isKinematic; matched case-insensitively, private fields writable too). component_get_serialized_properties / component_set_serialized_property use SerializedProperty paths (m_Mass, items.Array.data[0]; a bare mass is retried as m_Mass). To convert, drop m_ and lowercase the first letter; an m_ name sent to component_set_property fails with "Property/field not found" and lists the writable members.
  • Value source (component_set_property, its batch, batch_preview_set_property): exactly one of assetPath (project asset) > referencePath (scene object by path) / referenceName (by name, first match) > value, checked in that order; a lower one sent alongside is silently ignored. Sending none writes the type's default (0 / false / null).
  • value encoding: numbers and bools (true/false, 1/0, yes/no, on/off; others rejected) as JSON or strings; enums by member name, case-insensitive; vectors, Quaternion (3 values = euler, 4 = xyzw), Rect (x,y,w,h) and Bounds (cx,cy,cz,sx,sy,sz) as comma strings ("1,2,3"); colours as "r,g,b[,a]" (0–1), #RRGGBB[AA] or a name (red, green, blue, white, black, yellow, cyan, magenta, gray/grey, clear); LayerMask as a layer name or an integer mask. The JSON object form ({"x":1,"y":2,"z":3}, {"r":1,"g":0,"b":0}) works only for Vector2/3/4 and Color/Color32, with every component required (colour a defaults to 1; an explicit null counts as missing); partial objects, unknown keys and non-numbers are rejected naming the expected keys.
  • Read-back: component_set_property returns valueSet read from the component after the write, plus valueRequested only when the setter clamped or normalised it; component_set_serialized_property re-reads after applying. No follow-up read needed.
  • Property/add/remove batches: all-or-nothing — one failed item reverts the whole call (rolledBack:true, other items reverted:true); unknown item keys are named in warnings.

Skills Overview

Invocation batches are non-atomic async jobs; details: method calls.

Single Batch
component_add component_add_batch
component_get_methods component_get_methods_batch
component_invoke_method component_invoke_method_batch
component_remove component_remove_batch
component_set_property component_set_property_batch
component_set_serialized_property component_set_serialized_property_batch

No batch: component_list (types and enabled state), component_get_properties (C# members and values), component_get_serialized_properties (Inspector paths), component_copy, component_copy_exact (verifies every serialized field), component_set_enabled (Behaviour/Renderer/Collider on or off — not component_set_property).

Per-skill tables, item fields and return shapes: reference/<skill_name>.md — rarely needed, the schema notes the parameters.

DO NOT (common hallucinations):

  • component_create / component_get do not exist → use component_add (add) and component_get_properties (read)
  • component_find does not exist → use component_list to list components on an object

Exact Signatures

Names, parameters, defaults and required flags come from GET /skills/schema?category=Component (or ?names=a,b), not this file.

Common Errors

Error Trigger → fix
TARGET_NOT_FOUND Object, component type, component on the object, member or asset missing → component_list, component_get_properties, asset_find, gameobject_find.
MISSING_PARAM e.g. componentType, propertyName, propertyPath → supply it; the error (or a dryRun) lists all parameters.
SEMANTIC_INVALID A value the target type rejects, componentIndex out of range, a component another one still requires (requiredBy: remove those first), or a failed batch item → fix per the message / results.
SKILL_ERROR Read-only property → pick a writable member.

Transport codes (COMPILING, RATE_LIMIT, ...) → error codes.

Version History

  • 67cd2ca Current 2026-10-18 21:38

    同步2.9.1技能集文档,更新技能计数与模块文档,调整NeverInSemi列表以包含component_invoke_method*等高危技能,修正部分技能的返回形状描述。

  • 8c31c5a 2026-08-27 12:43

    修复模块文档审计问题,更新地址资源相关文档,修正幽灵场景引用、自动权限流程误导及缺失参数等错误。

  • 5ee8388 2026-08-17 04:10

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

  • 25d511e 2026-08-13 09:13

    压缩75个SKILL.md description至约5191字符,并将路由说明移入Triggers部分。

  • e49379b 2026-07-31 06:53

    版本升级至2.4.0

  • ec9f870 2026-07-05 14:39

Same Skill Collection

SkillsForUnity/unity-skills~/skills/addressables-design/SKILL.md
SkillsForUnity/unity-skills~/skills/addressables/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/material/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/qframework-design/SKILL.md
SkillsForUnity/unity-skills~/skills/sample/SKILL.md
SkillsForUnity/unity-skills~/skills/shadergraph-design/SKILL.md
SkillsForUnity/unity-skills~/skills/skill-creator/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/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

Metadata

Files
0
Version
67cd2ca
Hash
ab218c45
Indexed
2026-07-05 14:39

홈 - 위키
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-10-20 02:30
浙ICP备14020137号-1