Getting started with MonoGame
This page sets up IcyUI in a MonoGame game.
Create a project from a MonoGame template:
dotnet new mgdesktopgl -o MyGameor
dotnet new mgwindowsdxfor the Direct3D backend. Both work with IcyUI.Retarget it to .NET 10. In
MyGame/MyGame.csproj, set<TargetFramework>net10.0</TargetFramework>(ornet10.0-windowsif the template used a-windowssuffix), and make sure the MonoGame packages are 3.8.5.1 or later.Add the package:
dotnet add MyGame/MyGame.csproj package IcyUI.MonoGame --prereleaseSet IcyUI up in your
Gameclass. CallUseIcyUI()inInitialize():using Icy.MonoGame.Configuration; using Icy.UI.Controls; using Microsoft.Xna.Framework; public class Game1 : Game { private readonly GraphicsDeviceManager graphics; public Game1() { graphics = new GraphicsDeviceManager(this); IsMouseVisible = true; } protected override void Initialize() { MonoGameIcyHost ui = this.UseIcyUI(); ui.MainCanvas.Add(new Button { Content = "Hello, IcyUI" }); base.Initialize(); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); base.Draw(gameTime); // IcyUI draws here, on top of what you drew above. } }UseIcyUI()adds IcyUI as a game component and returns the host:ui.MainCanvasis the canvas your elements go on, andui.Configurationholds every setting. The defaults load the built-in theme and use the system font Segoe UI. IcyUI draws duringbase.Draw(), after your own drawing; anything you draw afterbase.Draw()covers the UI. A string used as content becomes a TextBlock.Run the game. A "Hello, IcyUI" button appears and reacts to the mouse and keyboard.
Note
IcyUI doesn't ship a font. On Linux and macOS, or to use your own font, import a font file shipped with the game:
this.UseIcyUI(ui => ui.ConfigureFonts().ImportFont("Fonts/MyFont.ttf").WithDefaultFontFamily("My Font")). See
Fonts on other platforms. IcyUI's warnings appear in the debugger's Output
window.
Note
On the DesktopGL backend, touch input isn't available, and on Windows on ARM64 the game can hang when it exits. WindowsDX doesn't use the SDL layer behind both issues, but touch input and a clean exit on ARM64 haven't been verified there yet.
Next
Your first screen adds a menu described in markup.