gamedev-unity/skills/unity-skills/skills/event/SKILL.md
Wire UnityEvent persistent listeners at editor time — add, remove, and configure serialized event callbacks on components. Use when hooking up UnityEvents in the Inspector, wiring button or trigger callbacks, or scripting persistent listener setup, even if the user just says "事件绑定" or "按钮点击". 在编辑器期连接 UnityEvent 持久化监听器(在组件上添加、移除、配置序列化的事件回调);当用户要在 Inspector 里挂接 UnityEvent、连接按钮或触发器回调、或脚本化设置持久监听时使用。
npx skillsauth add bernatmv/ai-rules unity-eventInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Inspect and modify persistent listeners on UnityEvents (e.g. Button.onClick, Toggle.onValueChanged) — the same listeners you see in the Inspector's event drop slots.
event_get_listeners / event_list_events / event_get_listener_count,源码标 SkillMode.SemiAuto)直接执行;其余变更/调用类(event_add_listener / event_set_listener / event_set_listener_state / event_invoke / event_add_listener_batch / event_copy_listeners,标 SkillMode.FullAuto)需用户 grant,grant 后服务端一步执行返结果。event_remove_listener、event_clear_listeners 标记为 SkillOperation.Delete,被 IsForbiddenInSemi 静态拦截 —— 仅 Bypass 模式或加入 Allowlist 才能调用。event_invoke 只在 Play mode / runtime 下有效;编辑器空跑时仅触发 EditorAndRuntime 监听。event_add_listener 等写入的是 persistent listener(序列化到 prefab/scene),即可在编辑器时配置。DO NOT (common hallucinations):
event_create / event_trigger do not exist → UnityEvents are declared in component source code; this module only wires listenersevent_subscribe does not exist → use event_add_listenerevent_remove does not exist → use event_remove_listenerevent_add_listener requires exact component type and method name on the targetRouting:
xr module's xr_add_interaction_eventscript moduleevent_get_listenersGet persistent listeners of a UnityEvent. Parameters:
name / instanceId / path: Target GameObject locator.componentName (string): Component name.eventName (string): Event field name (e.g. "onClick").event_add_listenerAdd a persistent listener to a UnityEvent (Editor time). Parameters:
name / instanceId / path, componentName, eventName: Target event.targetObjectName, targetComponentName, methodName: Method to call.mode (string, optional): "RuntimeOnly", "EditorAndRuntime", "Off".argType (string, optional): "void", "int", "float", "string", "bool".floatArg, intArg, stringArg, boolArg: Argument value if needed.event_remove_listenerRemove a persistent listener by index. Parameters:
name / instanceId / path, componentName, eventName: Target event.index (int): Listener index.event_invokeInvoke a UnityEvent explicitly (Runtime only). Parameters:
name / instanceId / path, componentName, eventName: Target event.event_clear_listenersRemove all persistent listeners from a UnityEvent.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | name | string | No | null | GameObject name | | instanceId | int | No | 0 | GameObject instance ID | | path | string | No | null | GameObject hierarchy path | | componentName | string | No | null | Component name | | eventName | string | No | null | Event field name (e.g. "onClick") |
Returns: { success, removed }
event_set_listener_stateSet a listener's call state (Off, RuntimeOnly, EditorAndRuntime).
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | name | string | No | null | GameObject name | | instanceId | int | No | 0 | GameObject instance ID | | path | string | No | null | GameObject hierarchy path | | componentName | string | No | null | Component name | | eventName | string | No | null | Event field name | | index | int | No | 0 | Listener index | | state | string | No | null | Call state: "Off", "RuntimeOnly", or "EditorAndRuntime" |
Returns: { success, index, state }
event_set_listenerReplace a persistent listener at a specific index.
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| name | string | No | null | GameObject name |
| instanceId | int | No | 0 | GameObject instance ID |
| path | string | No | null | GameObject hierarchy path |
| componentName | string | No | null | Source component name |
| eventName | string | No | null | Event field name |
| index | int | No | 0 | Listener index to replace |
| targetName | string | No | null | Target GameObject name |
| targetInstanceId | int | No | 0 | Target GameObject instance ID |
| targetPath | string | No | null | Target hierarchy path |
| targetComponentName | string | No | null | Target component name, or GameObject |
| methodName | string | No | null | Public method or set_PropertyName |
| mode | string | No | RuntimeOnly | Off, RuntimeOnly, or EditorAndRuntime |
| argType | string | No | void | void, int, float, string, bool, object |
| floatArg | float | No | 0 | Static float argument |
| intArg | int | No | 0 | Static int argument |
| stringArg | string | No | null | Static string argument |
| boolArg | bool | No | false | Static bool argument |
| objectReferenceName | string | No | null | Scene object argument name |
| objectReferenceInstanceId | int | No | 0 | Scene object argument instance ID |
| objectReferencePath | string | No | null | Scene object argument path |
| objectAssetPath | string | No | null | Project asset argument path |
| objectType | string | No | null | Object/component type for object argument |
Returns: { success, index, target, targetType, method, state, argType }
event_list_eventsList all UnityEvent fields on a component.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | name | string | No | null | GameObject name | | instanceId | int | No | 0 | GameObject instance ID | | path | string | No | null | GameObject hierarchy path | | componentName | string | No | null | Component name |
Returns: { success, component, count, events }
event_add_listener_batchAdd multiple listeners at once. items: JSON array of {targetObjectName, targetComponentName, methodName}.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | name | string | No | null | GameObject name | | instanceId | int | No | 0 | GameObject instance ID | | path | string | No | null | GameObject hierarchy path | | componentName | string | No | null | Component name | | eventName | string | No | null | Event field name | | items | string | No | null | JSON array of {targetObjectName, targetComponentName, methodName} |
Returns: { success, added, total }
event_copy_listenersCopy listeners from one event to another.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | sourceObject | string | Yes | - | Source GameObject name | | sourceComponent | string | Yes | - | Source component name | | sourceEvent | string | Yes | - | Source event field name | | targetObject | string | Yes | - | Target GameObject name | | targetComponent | string | Yes | - | Target component name | | targetEvent | string | Yes | - | Target event field name |
Returns: { success, copied }
event_get_listener_countGet the number of persistent listeners on a UnityEvent.
| Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | name | string | No | null | GameObject name | | instanceId | int | No | 0 | GameObject instance ID | | path | string | No | null | GameObject hierarchy path | | componentName | string | No | null | Component name | | eventName | string | No | null | Event field name |
Returns: { success, count }
Exact names, parameters, defaults, and returns are defined by GET /skills/schema or unity_skills.get_skill_schema(), not by this file.
development
Keyword research and validation with real search-demand data — never ship keywords from intuition alone. Probes Google Autocomplete per language (free, no account) to prove demand and discover the exact phrasing people type, checks SERPs for winnability, and uses Keyword Planner/Ahrefs/Semrush exports when the user has access. Activates when: choosing or reviewing SEO keywords, meta keywords, page titles, article topics or slugs, landing page copy targeting search, App Store/ASO keyword fields, multilingual keyword sets, 'what should we rank for', 'keyword analysis', or auditing why a page doesn't rank. Also invoke it as a validation pass whenever another skill or task produces a keyword list.
development
Automate YooAsset hot-update and asset bundles — build bundles, run Editor simulate builds, manage Collector groups, analyze BuildReport, and validate runtime. Use when building or simulating YooAsset bundles, configuring collectors, or validating hot-update assets, even if the user just says "热更" or "打AB包". 自动化 YooAsset 热更新与资源包(构建 bundle、编辑器模拟构建、管理 Collector 分组、分析 BuildReport、运行时校验);当用户要构建或模拟 YooAsset 资源包、配置 collector、或校验热更资源时使用。
development
Source-anchored design rules for YooAsset v2.3.18 — initialization, default-package shortcuts, play modes, asset handles, loading, updates, filesystem, build, and pitfalls. Use when writing or reviewing YooAsset code, initializing packages, loading assets via handles, setting up hot-update/download, or choosing a play mode, even if the user just says "热更" or "资源包". 为 YooAsset v2.3.18 提供源码锚定的设计规则(初始化、默认包快捷方式、运行模式、资源句柄、加载、更新、文件系统、构建、陷阱);当用户要编写或审查 YooAsset 代码、初始化 package、用句柄加载资源、配置热更/下载、或选择运行模式时使用。
data-ai
Last-resort guidance for safely hand-editing Unity serialized YAML (.unity/.prefab/.asset/.meta/ProjectSettings) — reference/fileID repair, GUID safety, and merge-conflict fixes. Use when REST cannot reach the change and YAML must be hand-edited — fixing m_Script GUIDs, broken fileID references, .meta files, or merge conflicts, even if the user just says "场景文件打不开" or "引用丢了". 安全手编 Unity 序列化 YAML(.unity/.prefab/.asset/.meta/ProjectSettings)的最后手段(引用/fileID 修复、GUID 安全、合并冲突修复);当 REST 无法触达、必须手编 YAML 时使用——修复 m_Script GUID、断裂 fileID 引用、.meta 文件或合并冲突。