Repository navigation
Getting Started
This section will help you get up and running with Myra UI Generator quickly.
Before installing Myra UI Generator, ensure you have:
- .NET Standard 2.0 or later
- Myra UI library installed in your project
- MonoGame (or compatible framework)
- A .NET IDE (Visual Studio, VS Code, or JetBrains Rider)
Install-Package MyraUIGeneratordotnet add package MyraUIGeneratorAdd to your .csproj file:
<ItemGroup>
<PackageReference Include="MyraUIGenerator" Version="1.0.9" />
</ItemGroup>After installation, rebuild your project. The generator will run automatically during compilation. You should see generated files in your obj/ directory (they're typically hidden in the IDE).
Check the build output for diagnostic messages starting with MYRA to confirm the generator is running.
Get your first UI class generated in 5 minutes:
Create a file Content/UI/TitleScreen.xml:
<Project>
<Label Id="TitleLabel" Text="Welcome to My Game" />
<Button Id="StartButton" Content="Start Game" />
<Button Id="ExitButton" Content="Exit" />
</Project>In your .csproj, add:
<ItemGroup>
<AdditionalFiles Include="Content/UI/*.xml" />
</ItemGroup>Create or update .editorconfig in your project root:
[*.cs]
myra_ui_generator.namespace = MyGame.UI.Generated
myra_ui_generator.xml_directory = Content/UIBuild your project, then use the generated class:
using MyGame.UI.Generated;
using Myra.Graphics2D.UI;
// Load the UI
var project = UiLoader.Load("TitleScreen.xml");
// Create and initialize the generated class
var ui = new TitleScreenUI();
ui.Initialize(project.Root);
// Use strongly-typed access
ui.StartButton.Click += OnStartClicked;
ui.TitleLabel.Text = "Welcome!";
ui.ExitButton.IsEnabled = true;That's it! The generator creates TitleScreenUI with properties for each widget.
- Minimum: .NET Standard 2.0
- Recommended: .NET 6.0 or later
- Myra UI: Any version compatible with your MonoGame setup
- MonoGame: 3.8 or later (or compatible framework)
The generator works with any IDE that supports .NET source generators:
- ✅ Visual Studio 2019 16.9+ / Visual Studio 2022
- ✅ Visual Studio Code (with C# extension)
- ✅ JetBrains Rider 2021.1+
- ✅ Command line builds (
dotnet build)
- MSBuild 16.9+ (comes with Visual Studio)
- .NET SDK 5.0+ (for command line builds)
- Learn about Configuration options
- See Basic Usage patterns
- Check out Examples for complete working code
- Read the API Reference