sprite-editor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSprite Editor
Sprite编辑器
Sprite metadata (rects, borders, pivots, outlines) lives inside the importer, not in a file
you can edit — reaching it means running C# through a live Editor.
The skill owns getting you there — installing the CLI, confirming a connected
Editor, adding the project's package, telling a genuinely absent Editor
apart from one stuck in Safe Mode, and discovering the Editor's command catalog. Follow it
first; don't re-derive any of it here.
unity-clicom.unity.pipelineTwo things it can't know for you:
- You need in particular, not just a reachable Editor. Confirm it appears in the catalog — its presence depends on the Pipeline package version, not on the CLI.
eval - Never hand-edit a file to change sprite metadata. The importer owns that data and the capability checks below exist to prevent corruption, so an unreachable Editor is a stop, not a cue to improvise.
.meta
Run C# through the connected Editor with the command. Discover its parameter shape
from rather than assuming one — the inline form is
, and some Pipeline versions also register
for running a snippet from a file. Check the catalog before reaching for
; it is frequently absent. defaults to a 30 second timeout.
evalunity command --format jsonunity command eval --code '<snippet>'eval_fileeval_fileunity commandGenerates C# editor scripts to manipulate Unity sprites using ISpriteEditorDataProvider. Works with TextureImporter, PSBImporter, and custom importers.
精灵元数据(矩形、边框、轴心点、轮廓)存储在导入器中,而非可编辑的文件内——要访问这些数据,需通过运行中的Editor执行C#代码。
unity-clicom.unity.pipeline有两件事它无法为你确定:
- 你尤其需要命令,而非仅仅是可访问的Editor。请确认它出现在命令目录中——它是否存在取决于Pipeline包的版本,而非CLI。
eval - 切勿手动编辑文件来修改精灵元数据。导入器拥有这些数据的所有权,下文的能力检查正是为了防止数据损坏,因此若无法访问Editor,应停止操作,而非自行尝试其他方法。
.meta
使用命令通过已连接的Editor运行C#代码。请通过查看其参数格式,而非自行假设——内联形式为,部分Pipeline版本还注册了用于运行文件中的代码片段。在使用前请先检查命令目录;它通常不存在。默认超时时间为30秒。
evalunity command --format jsonunity command eval --code '<snippet>'eval_fileeval_fileunity command通过ISpriteEditorDataProvider生成C#编辑器脚本以操作Unity精灵。支持TextureImporter、PSBImporter及自定义导入器。
Passing C# to eval
eval向eval
传递C#代码
evaleval- No directives. The compiler reads
usingas a resource-disposal statement and rejects it (using UnityEngine;).CS0210 - Types must be fully qualified. A bare or
AssetDatabasedoes not resolve (Volume/CS0246), and a bareCS0103is ambiguous withObject(object).CS0104
Where a snippet below is written as a file — with usings, for readability, or because it is
meant to be saved into the project — qualify the types before passing it to .
evaleval- 不支持指令。编译器会将
using视为资源释放语句并拒绝执行(错误码using UnityEngine;)。CS0210 - 类型必须完全限定。直接使用或
AssetDatabase无法解析(错误码Volume/CS0246),直接使用CS0103会与Object产生歧义(错误码object)。CS0104
若下方的代码片段是以文件形式编写的——包含using语句以提升可读性,或需要保存到项目中——在传递给前,请先对类型进行完全限定。
evalWorkflow
工作流程
All generated scripts must follow the Safe Core Pattern in references/templates.md, which includes MANDATORY capability checks. NEVER attempt operations if capability checks fail - this prevents data corruption. After execution, verify results in Unity console and Project window.
所有生成的脚本必须遵循references/templates.md中的安全核心模式,其中包含强制能力检查。若能力检查失败,绝不能执行操作——这是为了防止数据损坏。执行完成后,请在Unity控制台及项目窗口中验证结果。
Common Operations
常见操作
Modify Name/Rect/Border/Pivot: Update corresponding fields (see scripts/SetPivotExample.cs for pivot examples)
SpriteRect- Requires: ,
EditSpriteName,EditSpriteRect, orEditBorderEditPivot
Add/Remove/Slice: Create or filter array (see references/background.md for Unity 2021.2+ requirements)
SpriteRect- Requires:
CreateAndDeleteSprite
Set Outlines: Get → Call with GUID + Vector2 arrays
ISpriteOutlineDataProviderSetOutlines()修改名称/矩形/边框/轴心点: 更新对应的字段(轴心点示例可查看scripts/SetPivotExample.cs)
SpriteRect- 所需权限:、
EditSpriteName、EditSpriteRect或EditBorderEditPivot
添加/删除/切片: 创建或筛选数组(Unity 2021.2+的要求请查看references/background.md)
SpriteRect- 所需权限:
CreateAndDeleteSprite
设置轮廓: 获取 → 使用GUID和Vector2数组调用
ISpriteOutlineDataProviderSetOutlines()Important Notes
重要注意事项
- Do NOT use AssetPostprocessor or MenuItem patterns
- Generate standalone snippets only — no , no
AssetPostprocessorMenuItem - Enum assignments: Always use enum values and cast to numeric types. Never use raw numbers.
- ✅ Correct:
(int)SpriteAlignment.Center - ❌ Wrong: (magic number)
1
- ✅ Correct:
- 请勿使用AssetPostprocessor或MenuItem模式
- 仅生成独立代码片段——不使用,不使用
AssetPostprocessorMenuItem - 枚举赋值: 始终使用枚举值并转换为数值类型。切勿使用原始数字。
- ✅ 正确:
(int)SpriteAlignment.Center - ❌ 错误:(魔术数字)
1
- ✅ 正确: