Setup for GumBatch (Optional)
Last updated
Last updated
Gum provides a GumBatch object which works similar to SpriteBatch. It can be used for immediate mode rendering, which allows for calling Begin
, Draw
, and End
just like SpriteBatch. This is useful if your project requires mixing Gum and MonoGame rendering, or if you are more comfortable using a SpriteBatch-like interface.
This page assumes you have an existing MonoGame project. This can be an empty project or an existing game.
Usage of GumBatch is completely optional, and it is only needed if you want to draw Gum objects at a partciular point in your drawing code. If you are using Gum to load .gumx projects, or if you would like Gum to handle all UI or HUD rendering, then you do not need to use GumBatch.
Open your MonoGame project in your preferred IDE.
Add the Gum.MonoGame
NuGet package
To initialize a GumBatch, you must:
Declare a GumBatch at class scope
Initialize the Gum SystemManagers - this is needed whether you use GumBatch or the full Gum retained mode rendering system
Initialize the GumBatch
(optional) load a .fnt file
Draw with gumBatch in your Draw
The following shows a simple Game1.cs file which renders Gum Text:
This code produces the following image:
Note that this code assumes a font .fnt file (and matching .png) are in the Content/Fonts/ folder. All content is loaded relative to the Content folder, just like normal content in MonoGame. Also note that this content does not use the content pipeline, but must be set to Copy to Output.
For more information on loading FNT files, see the File Loading documentation.
For a more detailed discussion of using GumBatch, see the GumBatch page.