AGENT SKILL

unity-event

UnityEvent persistent-listener wiring at editor time: inspect, add, remove, batch-add, copy, clear, set call-state, list events on a component (e.g. Button.onClick, Slider.onValueChanged). For runtime invocation only. Triggers: UnityEvent, event, persistent listener, persistent call, onClick, onValueChanged, listener, callback, wire, hook up, EditorAndRuntime, RuntimeOnly, button click, 事件, 持久监听器, 监听器, 接线, 回调, 按钮点击, 持久化.

License 许可
MIT
最近更新
2026-07-25
Stars
★ 8
Forks
0

01 前言 Front Matter

name
unity-event
metadata
{ "tier": 2, "source": "https://github.com/Besty0728/Unity-Skills", "version": "1.9.2" }
use-when
Load when the task requires: UnityEvent persistent-listener wiring at editor time: inspect, add, remove, batch-add, copy, clear, set call-state, list events on a component (e.g. Button.onClick, Slider.onValueChanged). For runtime invocation only. Unity Editor must be running with the unity-skills REST server reachable at http://localhost:8090.
platforms
[ "unity-editor", "claude-code" ]
description
UnityEvent persistent-listener wiring at editor time: inspect, add, remove, batch-add, copy, clear, set call-state, list events on a component (e.g. Button.onClick, Slider.onValueChanged). For runtime invocation only. Triggers: UnityEvent, event, persistent listener, persistent call, onClick, onValueChanged, listener, callback, wire, hook up, EditorAndRuntime, RuntimeOnly, button click, 事件, 持久监听器, 监听器, 接线, 回调, 按钮点击, 持久化.
do-not-use-when
Do not load when Unity Editor is not running locally. Do not load when unity-skills REST server is unreachable at http://localhost:8090. For XR interaction events → use `xr` module instead.
task-categories
[ "events", "messaging", "editor-automation" ]

03 SKILL.md 正文

Event Skills

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.

Operating Mode

  • Approval(默认):查询类 skill(event_get_listeners / event_list_events / event_get_listener_count,源码标 SkillMode.SemiAuto)直接执行;其余变更/调用类(event_add_listener / event_set_listener_state / event_invoke / event_add_listener_batch / event_copy_listeners,标 SkillMode.FullAuto)需用户 grant,grant 后服务端一步执行返结果。
  • Auto / Bypass:未被禁列表拦截的 skill 直接执行。
  • 本模块含 Delete 类 skill: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 listeners
  • event_subscribe does not exist → use event_add_listener
  • event_remove does not exist → use event_remove_listener
  • event_add_listener requires exact component type and method name on the target

Routing:

  • For XR interaction events → use xr module's xr_add_interaction_event
  • For C# event code → write via script module

Skills

event_get_listeners

Get 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_listener

Add 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_listener

Remove a persistent listener by index. Parameters:

  • name / instanceId / path, componentName, eventName: Target event.
  • index (int): Listener index.

event_invoke

Invoke a UnityEvent explicitly (Runtime only). Parameters:

  • name / instanceId / path, componentName, eventName: Target event.

event_clear_listeners

Remove 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_state

Set 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_list_events

List 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_batch

Add 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_listeners

Copy 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_count

Get 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 Signatures

Exact names, parameters, defaults, and returns are defined by GET /skills/schema or unity_skills.get_skill_schema(), not by this file.

04 同仓库更多 Skills

dyCuong03
dyCuong03/unity-agent-team

dots-update-groups

How to choose the right ECS system group and ordering so per-frame and per-fixed-step work is deterministic and never races its own readers. Covers InitializationSystemGroup / SimulationSystemGroup / PresentationSystemGroup / FixedStepSimulationSystemGroup / VariableRateSimulationSystemGroup, UpdateBefore / UpdateAfter peer ordering, OrderFirst / OrderLast group-boundary placement, RateManager, and the cross-group ordering trap. Use when adding an ISystem, fixing "value visible one frame late" bugs, or coupling simulation to a fixed timestep.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-transform-patterns

The Entities 1.x transform model — LocalTransform (writable input) vs LocalToWorld (system-owned matrix), Parent/Child hierarchy, reparenting cost, uniform vs non-uniform scale (PostTransformMatrix), and when to opt out with custom transform systems. Use when designing parent/child hierarchies, runtime reparenting (mount/dismount/socket), or choosing transform components at the Baker boundary.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-singleton-patterns

Model cross-system shared configuration and game state as a single-entity component with a strict single-writer contract. Covers RequireForUpdate gating, SystemAPI.GetSingleton / GetSingletonRW / HasSingleton / TryGetSingleton, bake-time vs runtime-created vs ECB-system singletons, the "exactly one entity" runtime invariant, and the single-writer rule. Use when designing frame-stable global config, shared mutable state, or any component intended to exist on exactly one entity.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-hybrid-bridge

The one-way bridge between DOTS-owned runtime state and Unity-owned presentation. Covers UnityObjectRef for managed asset refs in components, the DOTS-writes / Unity-reads ownership rule, when to use managed IComponentData vs UnityObjectRef vs CompanionComponent, baker-bridge vs runtime-bridge, and SubScene boundary rules. Use when an entity must reference Unity assets (Mesh, Material, AudioClip, ScriptableObject), a MonoBehaviour view must read entity state, or input/UI must trigger ECS work.

★ 8
dyCuong03
dyCuong03/unity-agent-team

dots-event-driven-ecs

Model one-frame events and external requests in ECS without dual ownership, polling, or persistent state leaks. Covers request-tag pattern with ECB, enableable command components (no structural change), event buffers (IBufferElementData), explicit consumer ownership, one-frame latency rules, and the banned C# event / UnityEvent / static bus anti-patterns. Use when input/UI/network must trigger ECS work, when a one-frame signal fans out to N consumers (damage, hit, collision), or when state changes must be processed exactly once.

★ 8
dyCuong03
dyCuong03/unity-agent-team

valid_skill

A complete, well-formed test fixture skill for SkillHub validation testing. Covers basic task routing and code review for Unity projects.

★ 8