Unity Editor Tools by juliankerignard/unity-skills
npx skills add https://github.com/juliankerignard/unity-skills --skill 'Unity Editor Tools'此技能为 Unity 编辑器生成自定义工具,以加速开发工作流程。它涵盖了所有类型的编辑器扩展:CustomEditor、PropertyDrawer、EditorWindow、MenuItem、ScriptableWizard 和 AssetPostprocessor。
Assets/Scripts/ 结构的 Unity 项目创建哪种类型的编辑器工具?
| 需求 | 类型 | 基类 |
|---|---|---|
| 自定义组件在 Inspector 中的显示 | CustomEditor | Editor |
| 自定义特定类型字段的渲染 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
PropertyDrawer |
PropertyDrawer |
| 创建独立的工具窗口 | EditorWindow | EditorWindow |
| 在菜单中添加快速操作 | MenuItem | 静态属性 |
| 创建分步向导 | ScriptableWizard | ScriptableWizard |
| 在导入时处理资源 | AssetPostprocessor | AssetPostprocessor |
分析用户需求。扫描现有组件:
Glob : Assets/Scripts/**/*.cs
Grep : "class.*MonoBehaviour" 在找到的文件中
关键问题:哪个组件需要更轻松地编辑?哪个操作需要自动化?缺少什么视觉反馈?
在生成代码之前,检查 Editor 基础设施是否存在:
1. Glob : Assets/**/Editor/*.asmdef 或 Assets/**/Editor.asmdef
2. 如果不存在:创建文件夹 Assets/Scripts/Editor/
3. 创建引用 Game.Runtime 的 Game.Editor.asmdef
4. 检查 .asmdef 是否仅针对 Editor 平台
Game.Editor.asmdef 文件结构:
{
"name": "Game.Editor",
"rootNamespace": "",
"references": ["Game.Runtime"],
"includePlatforms": ["Editor"],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false
}
如果不存在 Game.Runtime.asmdef,使用 Glob 在 Assets/Scripts/ 中检查,并在必要时创建一个。
模板可在 references/editor-templates.md 中找到:
| 模板 | 基类 | 用途 |
|---|---|---|
| CustomEditor (IMGUI) | Editor | 自定义 Inspector,兼容所有版本 |
| CustomEditor (UI Toolkit) | Editor | Unity 6+ 的复杂 Inspector,自动绑定 |
| PropertyDrawer | PropertyDrawer | 自定义字段类型的渲染 |
| EditorWindow | EditorWindow | 带标签页和工具栏的工具窗口 |
| MenuItem | 静态属性 | Unity 菜单中的快速操作 |
对于 Unity 6+,对于复杂的 EditorWindow 和 CustomEditor,优先使用 UI Toolkit 而非 IMGUI。对于简单的 PropertyDrawer,IMGUI 仍然可以接受。
生成脚本后:
Assets/Scripts/Editor/ 或 Assets/Editor/)using UnityEditor;Assets/Scripts/Editor/ 或 Assets/Editor/includePlatforms: ["Editor"] 的程序集定义 Game.EditorserializedObject.Update() 和 ApplyModifiedProperties()Undo.RecordObject()EditorGUI.BeginProperty/EndPropertytarget(使用 (T)target 或 serializedObject)GUIContent.noneAssets/Scripts/ 根目录下创建编辑器文件/unity-code-gen (Unity Code Gen)/uitk (Unity UI Toolkit)/unity-test (Unity Test)| 问题 | 解决方案 |
|---|---|
找不到类型或命名空间 'Editor' | 脚本不在 Editor 文件夹中,或者程序集定义缺少 includePlatforms: ["Editor"] |
| 自定义 Inspector 不显示 | 检查 typeof(TargetComponent) 是否与目标类型完全匹配,以及脚本是否编译 |
OnEnable 中的 NullReferenceException | FindProperty() 中的属性名称与 [SerializeField] 字段不匹配(区分大小写) |
| PropertyDrawer 不生效 | 检查 [CustomPropertyDrawer(typeof(T))] 属性是否指向正确的类型,而不是字段 |
Multiple editors 警告 | 两个 CustomEditor 指向同一类型。在整个项目中 Grep 查找 CustomEditor(typeof(X)) |
| MenuItem 显示为灰色 | Validate 方法返回 false。检查验证条件 |
| 更改无法撤销 (Ctrl+Z) | 在每次直接修改之前添加 Undo.RecordObject() |
Weekly Installs
–
Repository
GitHub Stars
3
First Seen
–
Security Audits
Cette skill genere des outils personnalises pour l'editeur Unity afin d'accelerer les workflows de developpement. Elle couvre tous les types d'extensions editor : CustomEditor, PropertyDrawer, EditorWindow, MenuItem, ScriptableWizard et AssetPostprocessor.
Assets/Scripts/ existanteQuel type d'outil editor creer ?
| Besoin | Type | Classe de base |
|---|---|---|
| Personnaliser l'affichage d'un composant dans l'Inspector | CustomEditor | Editor |
| Personnaliser le rendu d'un type de champ specifique | PropertyDrawer | PropertyDrawer |
| Creer une fenetre d'outil autonome | EditorWindow | EditorWindow |
| Ajouter une action rapide dans un menu | MenuItem | attribut statique |
| Creer un assistant etape par etape | ScriptableWizard | ScriptableWizard |
| Traiter les assets a l'import | AssetPostprocessor | AssetPostprocessor |
Analyser le besoin utilisateur. Scanner les composants existants :
Glob : Assets/Scripts/**/*.cs
Grep : "class.*MonoBehaviour" dans les fichiers trouves
Questions cles : quel composant editer plus facilement ? Quelle action automatiser ? Quel feedback visuel manque ?
Avant de generer du code, verifier que l'infrastructure Editor existe :
1. Glob : Assets/**/Editor/*.asmdef OR Assets/**/Editor.asmdef
2. Si absent : creer le dossier Assets/Scripts/Editor/
3. Creer Game.Editor.asmdef avec reference a Game.Runtime
4. Verifier que le .asmdef cible uniquement la plateforme Editor
Structure du fichier Game.Editor.asmdef :
{
"name": "Game.Editor",
"rootNamespace": "",
"references": ["Game.Runtime"],
"includePlatforms": ["Editor"],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false
}
Si aucun Game.Runtime.asmdef n'existe, verifier avec Glob dans Assets/Scripts/ et en creer un si necessaire.
Templates disponibles dans references/editor-templates.md :
| Template | Base class | Usage |
|---|---|---|
| CustomEditor (IMGUI) | Editor | Inspector personnalise, compatible toutes versions |
| CustomEditor (UI Toolkit) | Editor | Inspector complexe Unity 6+, binding auto |
| PropertyDrawer | PropertyDrawer | Rendu custom d'un type de champ |
| EditorWindow | EditorWindow | Fenetre d'outil avec tabs et toolbar |
| MenuItem | Attribut statique | Action rapide dans un menu Unity |
Pour Unity 6+ , preferer UI Toolkit a IMGUI pour les EditorWindow et CustomEditor complexes. IMGUI reste acceptable pour les PropertyDrawer simples.
Apres generation du script :
Assets/Scripts/Editor/ ou Assets/Editor/)using UnityEditor; est presentAssets/Scripts/Editor/ ou Assets/Editor/Game.Editor avec includePlatforms: ["Editor"]serializedObject.Update() et ApplyModifiedProperties() dans les CustomEditorUndo.RecordObject() avant de modifier un objet via boutonEditorGUI.BeginProperty/EndProperty dans les PropertyDrawer/unity-code-gen (Unity Code Gen)/uitk (Unity UI Toolkit)/unity-test (Unity Test)| Probleme | Solution |
|---|---|
The type or namespace 'Editor' could not be found | Le script n'est pas dans un dossier Editor ou l'assembly def manque includePlatforms: ["Editor"] |
| L'inspector custom ne s'affiche pas | Verifier que typeof(TargetComponent) correspond exactement au type cible et que le script compile |
NullReferenceException dans OnEnable | Le nom de propriete dans FindProperty() ne correspond pas au champ [SerializeField] (sensible a la casse) |
Weekly Installs
–
Repository
GitHub Stars
3
First Seen
–
Security Audits
通过 LiteLLM 代理让 Claude Code 对接 GitHub Copilot 运行 | 高级变通方案指南
31,600 周安装
Agile Skill Build:快速创建和扩展ace-skills的自动化工具,提升AI技能开发效率
1 周安装
LLM评估工具lm-evaluation-harness使用指南:HuggingFace模型基准测试与性能分析
212 周安装
Agently TriggerFlow 状态与资源管理:runtime_data、flow_data 和运行时资源详解
1 周安装
Agently Tools 工具系统详解:Python 代理工具注册、循环控制与内置工具使用
1 周安装
Agently Prompt配置文件技能:YAML/JSON提示模板加载、映射与导出指南
1 周安装
iOS/Android推送通知设置指南:Firebase Cloud Messaging与React Native实现
212 周安装
target sans cast dans un CustomEditor (utiliser (T)target ou serializedObject)GUIContent.none quand on dessine des sous-champs dans un DrawerAssets/Scripts/| Le PropertyDrawer ne s'applique pas | Verifier que l'attribut [CustomPropertyDrawer(typeof(T))] cible le bon type, pas le champ |
Multiple editors warning | Deux CustomEditor ciblent le meme type. Grep pour CustomEditor(typeof(X)) dans tout le projet |
| Le MenuItem est grise | La methode Validate retourne false. Verifier les conditions de validation |
| Changements non annulables (Ctrl+Z) | Ajouter Undo.RecordObject() avant chaque modification directe |