unity-observer-pattern
Reactive Property system for Unity. Decouples data from UI and logic using observable wrappers and UnityEvents.
How do I install this agent skill?
npx skills add https://github.com/muharremtozan/unity-agent-skills --skill unity-observer-patternIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill provides a standard implementation of the Observer pattern for Unity development using reactive properties. It includes generic wrappers for variables and specialized editor tooling. No security risks or malicious patterns were detected.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
Unity Observer Pattern (Reactive Properties)
A powerful implementation of the Observer pattern that turns standard variables into "Smart Properties." Includes full Inspector support and Edit-mode tooling based on the "Generic Observer" architecture.
Core Features
- Hybrid Path: Works with standard C# listeners (Pro Path) AND UnityEvents (Designer/Light Path).
- Implicit Casting: Seamless syntax allows
int x = myObservableInt;(no more.Valueboilerplate). - Editor Persistence: Programmatically wire persistent calls in Edit Mode that save to scene/prefab.
- Diagnostic Logging: Built-in structured logging for tracking event flows.
Core Files (Max 3)
Observable.cs.txt: The core generic wrapper with implicit casting and built-in editor wiring.ObservableEditorTools.cs.txt: Advanced reflection hacks for clearing persistent UnityEvents.ObservableExample.cs.txt: Concrete example demonstrating UI binding and lifecycle management.
Usage
Option A: The Light Path (Inspector)
- Define a field:
public Observable<int> health;. - In Unity Inspector, drag your UI method into the
On Value Changedlist.
Option B: The Pro Path (Code)
health.AddListener( val => Debug.Log( val ) );
health.Value = 50; // Automatically triggers notification
Option C: Implicit Usage
int currentHealth = health; // Works automatically via implicit operator
Cleanup
Always call RemoveListener or Dispose in OnDisable to prevent memory leaks.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/muharremtozan/unity-agent-skills/unity-observer-pattern">View unity-observer-pattern on skillZs</a>