generate-editor-search-query

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Translate natural-language Unity Editor search requests into useful Unity Search queries, explain them briefly, and open the Unity Search window with the query when appropriate.
将自然语言的Unity Editor搜索请求转换为实用的Unity Search查询,简要说明查询内容,并在适当的时候使用该查询打开Unity Search窗口。

Default Behavior

默认行为

If the prompt explicitly says Unity Search, Quick Search, Search window, open Search, or asks for a Unity Search query, handle the search request with this skill even when the target belongs to another domain such as lighting, UI, physics, audio, or animation.
For requests such as "find", "search", "locate", "list", "filter", "look up", "where is", "which assets use", or "what references" concrete Unity assets or scene objects:
  1. Determine whether the request is primarily about project assets, scene objects, or both.
  2. Build one concise Unity Search query.
  3. Show the query in the response before or while opening Search.
  4. Open Unity Search by running the Editor-side snippet unless the user explicitly asks for query text only.
  5. If opening Search fails, return the query and tell the user to paste it into Unity Search manually.
Do not open Search when the user says "do not open Search", "query only", "what query should I use", "just give me the query", or similar.
If the user asks for a general explanation, project overview, folder-structure summary, architecture walkthrough, gameplay-system summary, or "how do I" programming answer, do not use this skill unless the prompt explicitly asks for Unity Search, a Search query, or opening the Search window.
If the user refers to "this", "selected", or "current" without an attached asset, scene object, visible name, or path, ask for the name/path instead of inventing one.
如果提示中明确提及Unity Search、Quick Search、搜索窗口、打开搜索,或要求提供Unity Search查询,即使搜索目标属于灯光、UI、物理、音频、动画等其他领域,也应使用本技能处理搜索请求。
对于诸如「查找」「搜索」「定位」「列出」「筛选」「查询」「在哪里」「哪些资源使用了」「什么引用了」具体Unity资源或场景对象的请求:
  1. 判断请求主要针对项目资源、场景对象,还是两者皆有。
  2. 构建一条简洁的Unity Search查询。
  3. 在打开搜索窗口之前或同时,在响应中展示查询语句。
  4. 除非用户明确要求仅提供查询文本,否则通过运行Editor端代码片段打开Unity Search。
  5. 如果打开搜索窗口失败,返回查询语句并告知用户手动将其粘贴到Unity Search中。
当用户表示「不要打开搜索」「仅查询」「我应该用什么查询」「只给我查询语句」或类似表述时,请勿打开搜索窗口。
如果用户要求通用说明、项目概览、文件夹结构总结、架构梳理、玩法系统总结,或「如何实现」类编程问题,请勿使用本技能,除非提示中明确要求使用Unity Search、提供搜索查询或打开搜索窗口。
如果用户提及「这个」「选中的」或「当前的」,但未附带相关资源、场景对象、可见名称或路径,请询问名称/路径,而非自行编造。

Scope

适用范围

Scope read-only Unity Search / Quick Search queries to:
  • project assets such as materials, textures, prefabs, scenes, scripts, shaders, audio clips, sprites, meshes, models, animations, fonts, render textures, and ScriptableObject assets
  • scene objects and components such as Cameras, Lights, Rigidbodies, Colliders, Renderers, Canvas objects, UI components, ParticleSystems, AudioSources, Animators, Terrain objects, and named GameObjects
  • path, label, type, filename, keyword, and reference-oriented asset searches
  • selected or named assets when the name/path is available from the conversation or attachment
Do not install packages, run menu commands, edit assets, modify scenes, search external documentation, search repository text, inspect build logs, delete results, fix search results, or perform dependency graph analysis. If the user asks to act on results, first open Search or provide the query, then ask for confirmation before any separate modifying skill or workflow.
将只读的Unity Search / Quick Search查询范围限定为:
  • 项目资源,如materials、textures、prefabs、scenes、scripts、shaders、音频片段、sprites、meshes、models、animations、fonts、render textures、ScriptableObject资源
  • 场景对象和组件,如Cameras、Lights、Rigidbodies、Colliders、Renderers、Canvas对象、UI组件、ParticleSystems、AudioSources、Animators、Terrain对象、命名的GameObjects
  • 基于路径、标签、类型、文件名、关键词和引用的资源搜索
  • 当对话或附件中提供了名称/路径时,可搜索选中或命名的资源
请勿安装包、运行菜单命令、编辑资源、修改场景、搜索外部文档、搜索仓库文本、检查构建日志、删除结果、修复搜索结果或执行依赖图分析。如果用户要求对搜索结果执行操作,请先打开搜索窗口或提供查询语句,然后在调用任何单独的修改类技能或工作流之前请求用户确认。

References

参考资料

Before generating non-trivial queries, read references/query-patterns.md.
Before opening the Search window, read references/open-search-window.md.
Official English references:
生成非平凡查询之前,请阅读references/query-patterns.md。
打开搜索窗口之前,请阅读references/open-search-window.md。
官方英文参考资料:

Passing C# to
eval

向
eval
传递C#代码

eval
compiles a statement block, not a file. Two consequences, both compile errors:
  • No
    using
    directives.
    The compiler reads
    using UnityEditor;
    as a resource-disposal statement and rejects it (
    CS0210
    ).
  • Types must be fully qualified. A bare
    SearchService
    does not resolve (
    CS0246
    ), and a bare
    Object
    is ambiguous with
    object
    (
    CS0104
    ).
The
unity-cli
skill owns the prerequisites — installing the CLI, confirming a connected Editor, adding the project's
com.unity.pipeline
package, and discovering the command catalog. You need
eval
in particular; if it is absent, generate the query text and say the window can't be opened.
eval
编译的是语句块,而非文件。这会导致两个编译错误:
  • 不支持
    using
    指令。
    编译器会将
    using UnityEditor;
    读取为资源释放语句并拒绝它(错误码
    CS0210
    )。
  • 类型必须完全限定。 直接写
    SearchService
    无法解析(错误码
    CS0246
    ),直接写
    Object
    会与
    object
    产生歧义(错误码
    CS0104
    )。
unity-cli
技能负责前置准备工作——安装CLI、确认已连接Editor、添加项目的
com.unity.pipeline
包,以及发现命令目录。你特别需要
eval
功能;如果没有
eval
,则生成查询文本并说明无法打开窗口。

Query Generation Rules

查询生成规则

Use the simplest query that is likely to produce the requested result.
  • Prefer type filters for asset and component requests, such as
    t:material
    ,
    t:texture
    ,
    t:prefab
    ,
    t:scene
    ,
    t:script
    ,
    t:shader
    ,
    t:Light
    , or
    t:Rigidbody
    .
  • Preserve user-provided names and keywords as plain query terms unless they need quoting.
  • Use
    dir:
    when the user gives a folder or says "in Assets/..." or "under ...".
  • Use
    l:
    when the user asks for a Unity asset label.
  • Use
    ref=
    when the user asks what references, uses, depends on, contains, or is connected to an asset.
  • Use Search expressions only when they clearly improve the query, such as
    t:prefab ref={t:texture}
    or
    t:scene ref={t:prefab}
    .
  • For selected/current wording, use the known selected asset name or path only if it is present in the chat context; otherwise ask for it.
  • For broad relationship requests such as "where is Rigidbody used", use a simple keyword or component query first, then mention that a scripted audit is separate if the user needs exhaustive code/property analysis.
  • For requests that mix Search with repair work, generate and open the query first; do not modify results unless the user explicitly confirms a separate follow-up action.
  • Do not invent unsupported filters for uncertain requests. If a request cannot be expressed reliably with Unity Search syntax, open the closest safe query and state the limitation.
使用最有可能产生请求结果的最简单查询。
  • 优先对资源和组件请求使用类型过滤器,例如
    t:material
    、
    t:texture
    、
    t:prefab
    、
    t:scene
    、
    t:script
    、
    t:shader
    、
    t:Light
    或
    t:Rigidbody
    。
  • 保留用户提供的名称和关键词作为普通查询词,除非需要加引号。
  • 当用户指定文件夹或说「在Assets/...中」「在...下」时,使用
    dir:
    。
  • 当用户要求查找Unity资源标签时,使用
    l:
    。
  • 当用户询问什么引用了、使用了、依赖了、包含了或关联了某个资源时,使用
    ref=
    。
  • 仅当搜索表达式能明显优化查询时才使用,例如
    t:prefab ref={t:texture}
    或
    t:scene ref={t:prefab}
    。
  • 对于「选中的/当前的」这类表述,仅当聊天上下文中存在已知的选中资源名称或路径时才使用;否则请询问用户。
  • 对于宽泛的关联请求,例如「Rigidbody用在哪里」,请先使用简单的关键词或组件查询,然后说明如果用户需要详尽的代码/属性分析,脚本化审计是单独的功能。
  • 对于混合了搜索和修复工作的请求,请先生成并打开查询;除非用户明确确认后续单独操作,否则不得修改结果。
  • 对于不确定的请求,请勿编造不支持的过滤器。如果某个请求无法用Unity Search语法可靠表达,请打开最接近的安全查询并说明局限性。

Opening Unity Search

打开Unity Search

Run C# in the Editor only to open the Search window. This is an Editor UI action and must not change project assets or scene contents.
When opening Search:
  1. Escape the query safely in the generated C# string.
  2. Prefer asset and scene providers for this v1 skill.
  3. Fall back to active providers if a provider is unavailable.
  4. Log the query that was opened.
  5. Never claim Search opened if the command failed.
仅在Editor中运行C#代码以打开搜索窗口。这是Editor UI操作,不得更改项目资源或场景内容。
打开搜索窗口时:
  1. 在生成的C#字符串中安全转义查询语句。
  2. 本v1版本技能优先使用资源和场景提供程序(provider)。
  3. 如果某个提供程序不可用,则回退到活动提供程序。
  4. 记录已打开的查询语句。
  5. 如果命令执行失败,绝不能声称搜索已打开。

Response Format

响应格式

Keep the user-facing response short:
text
Query: `t:material`
Opened Unity Search with that query.
If not opening Search:
text
Query: `t:prefab ref={t:texture}`
Paste this into Unity Search.
If the request is ambiguous but still searchable, choose the most likely query and mention the assumption. Ask a question only when the search target cannot be inferred, such as "find the thing" with no asset, scene, type, name, or context.
保持面向用户的响应简洁:
text
Query: `t:material`
Opened Unity Search with that query.
如果不打开搜索窗口:
text
Query: `t:prefab ref={t:texture}`
Paste this into Unity Search.
如果请求存在歧义但仍可搜索,选择最可能的查询并说明假设。仅当无法推断搜索目标时才提问,例如没有资源、场景、类型、名称或上下文的「找那个东西」这类请求。

Validation Checklist

验证检查清单

Before reporting success:
  • the generated query is shown to the user
  • the query targets assets, scene objects, or both
  • Search was opened only when the user did not opt out
  • any fallback or uncertainty is stated plainly
  • no asset, scene, package, project setting, or search result was modified
在报告成功之前,请确认:
  • 已向用户展示生成的查询语句
  • 查询针对资源、场景对象,或两者皆有
  • 仅当用户未选择退出时才打开搜索窗口
  • 已明确说明任何回退或不确定性
  • 未修改任何资源、场景、包、项目设置或搜索结果