MuharremTozan/Agentic-Duel / .agent/skills/unity-observer-pattern
unity-observer-pattern
UnverifiedReactive Property system for Unity. Decouples data from UI and logic using observable wrappers and UnityEvents.
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.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 318k | Updated | Claude CodeCodex | Unverified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |