Loading a Gum Project (Optional)
Introduction
Gum projects can be loaded in a game project. Gum projects are made up of multiple files including:
.gumx - the main Gum project
.gusx - Gum screen files
.gucx - Gum component files
.gutx - Gum standard element files
.png - image files
Creating a Gum Project
Before creating a Gum project, it is recommended that you already have a functional raylib-cs project. It's best to put your Gum project in its own folder, such as a subfolder of the resources
folder, so that it stays organized with your other of your content files. Remember, Gum creates lots of files.

If you haven't already downloaded it, you should download the Gum tool. See the Introduction page for information on downloading Gum.
To create a Gum project:
Open the Gum tool
Select File->New Project
Navigate to the desired subfolder (such as resources/GumProject/) to select a location for the project
Adding the Gum Project Files to Your .csproj
To add the files to your .csproj:
Open your .csproj file in a text editor
Add a line to copy all files in the Gum project folder including the .gumx file itself. For example, your csproj might look like this:
<None Update="resources\GumProject\**\*.*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
If using Visual Studio, you can verify that files are set to copy by selecting a random file in your Gum project and looking at the properties to see if it is marked as copied.

Loading a Gum Project
To load a Gum Project:
Open your file that has your Gum initialization code, such as Project.cs
Modify the Initialize method by passing it a Gum project
GumUI.Initialize(
"resources/GumProject/raylibGumProject.gumx");
var screen = ObjectFinder.Self.GumProjectSave.Screens
.First()
.ToGraphicalUiElement();
screen.AddToRoot();
The code above loads the Gum project using the file path "resources/GumProject/raylibGumProject.gumx"
. By default this path is relative to your game's exe folder.
ToGraphicalUiElement
Once a Gum project is loaded, all of its screens and components can be accessed through the object returned from the Initialize method. The gum project can be obtained by accessing ObjectFinder.Self.GumProjectSave
. Any screen or component can be converted to a GraphicalUiElement, which is the visual object that displays in game.
The code in the previous section creates a GraphicalUiElement
from the first screen in the project.
Calling AddToRoot adds the screen to the root Gum object and makes a fully-functional Gum screen, including any Forms instances, such as instances of the Button type.
Last updated
Was this helpful?