Nez
Introduction
Nez is a framework which adds additional functionality on top of MonoGame and FNA. Gum can be used with Nez since Nez ultimately exposes the MonoGame/FNA GraphicsDevice. Aside from setup, using Gum in Nez is identical to using Gum in any MonoGame project. Therefore, after setup you can reference the MonoGame section for usage details.
Setup
Nez projects use a game class which must inherit from Nez Core. This class ultimately inherits from the standard MonoGame Game class, so you can include overrides for Update and Draw just like any standard MonoGame project.
A typical game may look like is shown in the following code snippet:
public class Game1 : Core
{
protected override void Initialize()
{
base.Initialize();
MonoGameGum.GumService.Default.Initialize(Core.GraphicsDevice);
// Optional - adding a colored rectangle to make sure it all works:
var rectangle = new ColoredRectangleRuntime();
rectangle.Width = 100;
rectangle.Height = 100;
rectangle.Color = Color.White;
rectangle.AddToManagers(SystemManagers.Default, null);
Window.AllowUserResizing = true;
Scene = new BasicScene();
}
protected override void Update(GameTime gameTime)
{
SystemManagers.Default.Activity(gameTime.TotalGameTime.TotalSeconds);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
base.Draw(gameTime);
// Add System.Default.Draw after base.Draw or else graphics won't show up
MonoGameGum.GumService.Default.Draw();
}
}
If you have been able to get Gum working in a Nez project without any runtime errors, you are ready to start adding more complex UI to your game. Head on over to the MonoGame section for more information.
Troubleshooting
Could not load file or assembly 'MonoGame.Framework, Version=3.8.1.303
If you add the Gum code to your project, you may experience this exception internally from Nez:

The reason this is happening is because currently (as of July 2024) Nez links MonoGame 3.8.0 instead of 3.8.1 (the latest).
To solve this problem, your project must explicitly link MonoGame 3.8.1 or else you will have this exception.
To do this:
Open your project in Visual Studio
Expand the Dependencies item
Right-click on Packages and select Manage NuGet Packages
Right-click Manage NuGet Packages... option Click on the Browse tab
Search for MonoGame.Framework
Select the MonoGame.Framework NuGet package for your particular project type. This is most likely MonoGame.Framework.DesktopGL, but it may be different if you are targeting another platform.
MonoGame.Framework NuGet packages Click the Install button to add the NuGet package
After adding MonoGame, your NuGet packages should similar to the following image:

Last updated
Was this helpful?