MuharremTozan/Agentic-Duel / .agent/skills/unity-ui-data-binding
unity-ui-data-binding
VerifiedImplementation of MVVM-style Data Binding for Unity UI Toolkit using the [CreateProperty] attribute and BindableProperty wrappers.
Unity UI Toolkit Data Binding
Connect your game data (Model) to your interface (View) using modern high-performance data binding. This skill leverages Unity's unity.properties system to eliminate "Update" loop logic for UI updates.
Core Features
- BindableProperty: A wrapper class that uses
[CreateProperty]to expose values to the UI Toolkit binding engine. - MVVM (Model-View-ViewModel): Separates raw game data from UI-formatted data using a ViewModel mediator.
- Reactive Synchronization: UI elements update automatically when the underlying property value changes (or is polled by the engine).
- C# Based Binding: Set up complex bindings programmatically without relying on the UI Builder's inspector fields.
Core Files (Max 3)
BindableProperty.cs.txt: Generic property wrapper for data sources.BindingExample.cs.txt: Practical example showing a Coin display and Health bar bound to a ViewModel.
Usage
1. Define the ViewModel
Initialize BindableProperty fields that return formatted data from your model.
public BindableProperty<string> HealthText { get; }
HealthText = BindableProperty<string>.Bind(() => $"HP: {model.hp}/{model.maxHp}");
2. Set the Data Source
Assign your ViewModel to the dataSource property of your root VisualElement.
root.dataSource = myViewModel;
3. Establish the Binding
Use SetBinding on specific elements to link their properties (text, value, style) to paths in the ViewModel.
label.SetBinding("text", "HealthText.Value");
Key Principle
Always use one-way binding (ToTarget) for displays and two-way binding only for inputs (checkboxes, text fields). This keeps the "Source of Truth" in your Model.
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 | Verified | 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 |