skills/unity-app-ui-mvvm/SKILL.md
Expert for App UI MVVM pattern and dependency injection - ObservableObject, RelayCommand, AppBuilder, service registration, and DI. Use this skill whenever the user wants to create a ViewModel, bind data to UI elements, set up dependency injection, register services, implement commands for button actions, use [ObservableProperty] or [RelayCommand] attributes, create an AppBuilder, or structure their Unity App UI project with the MVVM architecture pattern. Also trigger when the user asks about data binding in UXML, property change notifications, or service lifetimes (transient, singleton, scoped).
npx skillsauth add cuozg/oh-my-skills unity-app-ui-mvvmInstall 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.
The MVVM (Model-View-ViewModel) pattern is a design pattern that separates user interface from business logic. Combined with Dependency Injection (DI), it creates a powerful architecture for building maintainable, testable, and scalable applications using Unity's UI Toolkit.
Use MVVM when you need to:
The Model is a simple data structure containing the data used by business logic. It has no knowledge of the UI.
The ViewModel contains business logic and is responsible for:
ViewModels connect to Views through data binding.
The View is the UI layer responsible for displaying data to the user. It should contain:
Views should never contain business logic.
Unity.AppUI.MVVM - Core MVVM classes and DIUnity.Properties - Property attributes and binding support┌─────────────────────────────────────────────┐
│ UIToolkitAppBuilder │
│ (Configures app and services) │
└──────────────────┬──────────────────────────┘
│
┌──────────┴──────────┐
│ │
v v
┌─────────┐ ┌──────────────┐
│ App │ │ Service │
│ │ │ Collection │
└────┬────┘ └──────────────┘
│
v
┌──────────────────┐
│ Views (UI) │◄──── Data Binding ◄─── ViewModels
│ │ Commands (Observable,
└──────────────────┘ RelayCommand)
Mark ViewModel properties with [ObservableProperty] to automatically generate property change notifications:
[ObservableObject]
public partial class MyViewModel
{
[ObservableProperty]
private string _name;
}
Use [RelayCommand] attributes to auto-generate command properties:
[ObservableObject]
public partial class MyViewModel
{
[RelayCommand]
private void SaveData()
{
// Execute command logic
}
}
Register services in AppBuilder.OnConfiguringApp():
appBuilder.services.AddSingleton<IMyService, MyService>();
appBuilder.services.AddTransient<MyViewModel>();
Inject services via constructor or [Service] attribute:
[ObservableObject]
public partial class MyViewModel
{
[Service]
public IMyService MyService { get; set; }
}
Use [AlsoNotifyChangeFor] to notify dependent properties:
[ObservableObject]
public partial class MyViewModel
{
[ObservableProperty]
[AlsoNotifyChangeFor(nameof(IsNameEmpty))]
private string _name;
public bool IsNameEmpty => string.IsNullOrEmpty(Name);
}
[ObservableObject] must be partial_fieldName)[Service] attribute for optional dependencies[RelayCommand] should describe the action (e.g., SaveData, DeleteItem)AddSingleton for stateless services (loggers, factories)AddTransient for stateful services (ViewModels, Pages)AddScoped for services tied to a specific scope[RelayCommand]
void DoSomething() { }
[RelayCommand]
void DoSomethingWith(string parameter) { }
[RelayCommand]
async Task DoSomethingAsync()
{
await Task.Delay(1000);
}
[RelayCommand(CanExecute = nameof(CanSave))]
void Save() { }
private bool CanSave => !string.IsNullOrEmpty(Name);
ViewModels expose observable properties and commands that bind to UI elements:
<ui:Button title="Save">
<Bindings>
<ui:DataBinding property="clickable.command" binding-mode="ToTarget" data-source-path="SaveCommand"/>
<ui:DataBinding property="enabledSelf" binding-mode="ToTarget" data-source-path="CanSave"/>
</Bindings>
</ui:Button>
Consult reference.md when you need exact API signatures for ObservableObject, RelayCommand, AppBuilder, or service container methods, full attribute parameter lists, advanced DI patterns like scoped lifetimes, or details on IDependencyInjectionListener and [CreateProperty]. See examples/ for complete MVVM app setups with multiple ViewModels and services.
tools
Generate Unity raster image assets through Unity MCP: game sprites, item art, backgrounds, UI icons, portraits, concept images, transparent cutouts, image edits, upscales, background removal, and Unity scene or Game View screenshots. Use when a Unity project needs image files imported under Assets or screenshots captured from the editor. Do not use for meshes, audio, animation, materials, gameplay code, UI Toolkit layout, or generic non-Unity image generation.
tools
Create Unity technical solution documents from user requirements, feature ideas, bug goals, specs, or codebase problems. Use when the user asks for a technical approach, architecture, implementation strategy, solution options, feasibility analysis, system design, or "how should we build/fix this" for Unity runtime, Editor, tools, assets, data, UI, WebGL, SDKs, or production pipelines.
tools
Orchestrate Unity Editor via MCP (Model Context Protocol) tools and resources. Use when working with Unity projects through MCP for Unity - creating/modifying GameObjects, editing scripts, managing scenes, running tests, or any Unity Editor automation. Provides best practices, tool schemas, and workflow patterns for effective Unity-MCP integration.
development
Convert a spec document into an implementation TODO list in the same spec folder. U se when the user says goal-todo, todo from spec, generate tasks from spec, turn this spec into todos, create implementation checklist, extract tasks, or asks to read a Docs/Specs design doc and produce what must be implemented. Includes UI/UX review and codebase investigation before writing the checklist. Do not use for implementing the tasks, creating new goal files, writing test cases, or verifying completed work.