Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Gum is an open source project so you can run it from source instead of running the pre-compiled project. Running from source is not a requirement, and is only needed if you intend to contribute to Gum or if you'd like to diagnose problems in a debugger.
Download the source file from GitHub
If you downloaded the .zip file from the GitHub main page, unzip the file
If you downloaded the file through a Git client, be sure to be on the main branch

Locate the Gum.slnx file (Gum.Wpf.sln is the older Windows-only WPF tool)
If you downloaded the .zip, it is in the root folder of the zip
If you cloned the repository, it is at the root of the Gum folder
Double-click it to open Visual Studio, or open Visual Studio and load the .slnx
Be sure to build solution rather than pressing F5 (which only builds the current project). This guarantees that all plugins are built and copied correctly. For more information see below.
Once the project has been built, you can run (with or without a debugger attached).
Gum depends on a number of plugins for its functionality. By default if you build the project and run it (such as by pressing F5 in Visual Studio), then plugins are not automatically built. To build plugins, you need to explicitly build all plugin projects. The easiest way to do this is to select the Build -> Rebuild Solution option in Visual Studio.

If your Editor Tab is missing, be sure to Build -> Build Solution. The Editor tab is a plugin, and you can verify that the plugin is in fact being built/loaded.
First view plugins:

Next, look for the Editor tab plugin in the list that appears:

If you are missing this, be sure to Build -> Build Solution.

If you have this popup, you need to set Gum as the startup project.
In Visual Studio:
Right-click on the Gum project (not the solution)
Select Set as Startup Project

The tutorials contained within this section provide an introduction to working with the Gum UI tool. This tutorial is a great place to start whether you are an artist who will be creating screens and components in Gum, or if you are a programmer who will be integrating Gum into your game or application.
If you are using Gum in a game project, you may want to continue reading other sections after you finish these tutorials.
Animation keyframes are defined by creating states in categories. If an animation uses two states in the same category then the animation will tween between them
Render targets and blend modes can be combined to create a silhouette of any shape. This example uses a Sprite with transparency. It uses the Bear.png file:
To create a Component that can display a Silhouette, first create a new component named SilhouetteSprite.
Add a ColoredRectangle instance and a Sprite instance. The order matters - the Sprite should be drawn on top of the ColoredRectangle (it should show up 2nd in the Project tree view).

For this example, we will use the Alignment tab to adjust each item:
SilhouetteSprite (main component) - Dock Size to Children
ColoredRectangleInstance - Dock Fill
The Sprite should already be sized according to its source file, although you can change this size if desired.
The ColoredRectangleInstance defines the color of the silhouette so change it to a desired color.
Your component should look similar to the following image:

Next we'll adjust the transparency values. To do this:
Set SilhouetteSprite Is Render Target to true
Set SpriteInstance Blend to MinAlpha
Your sprite's silhouette should now appear, using the underlying color as its own color.

The Has Events variable controls whether the selected instance supports UI-related events at runtime such as responding to a cursor click. If this value is false then events are not raised for this instance. If true, then cursor events are raised for this instance.
Usually instances of components should have this value set to true if the component can be interacted with at runtime, such as a button or text box.
This value has no effect in the Gum tool and is only used at runtime.
If an instance has its Has Events value unchecked then it will not be eligible to be assigned to the Cursor's WindowOver property. For more information, see the Cursor page.
Ignored By Parent Size determines whether the parent of an instance considers the instance when performing its sizing. This value is only used if the parent has a Height Units or Width Units of Relative To Children. If a parent has a Height Units or Width Units of any other value, then this value has no impact on the parent's size.

Ignored By Parent Size controls whether the parent ignores the child when performing a layoutThe Default Implementation property can be used to indicate which component is the default implementation for a behavior. This property is not used by the Gum tool, but instead exists for runtime implementations (such as FlatRedBall) to decide which type of component to create when an instance of a behavior is requested.

Behaviors are often used to help with the creation of components which need to have a certain set of states and instances. For example, the Button type in Gum Forms is associated with the ButtonBehavior.
At runtime, a game may need to create an instance of the Button type without specifying a component. For example, the following code can be used to create a button:
The Default Implementation property can help runtime libraries determine which component to create for the Button's visual.
The Button type is a good example of why this property might be needed because the default Forms components include multiple components which use ButtonBehavior.

To resolve this ambiguity, the ButtonBehavior's Default Implementation is automatically set to Controls/ButtonStandard.

For more information about whether you should set the Default Implementation, refer to the documentation for your particular runtime.
If you have created a custom runtime, such as a new ListBoxItem, you may need to change the Default Implementation for the ListBoxItem behavior.
The Blend variable controls how the selected instance combines its colors with whatever is drawn before. The final appearance of a NineSlice depends on its Blend, Alpha, Source File, and Color values.
For more information and examples, see the Sprite Blend page.
Components are reusable collections of instances. Components can be added in the project's Components folder. Examples of Components include:
Button
HealthBar
Slider
Menu
Components can be small and reusable, such as a Label, or they can be large complex objects such as a settings menu with dozens of options.
Component instances can be added to other Components or to Screens.
Shape properties are shared by the standard elements that draw vector shapes. Unlike General Properties, which every Standard Element and Component shares, shape properties only appear on shape elements such as Circle and Rectangle.
These properties control how a shape is filled, whether it draws a gradient, and whether it casts a dropshadow:
The following element types expose these properties:
Circle and Rectangle - the core (non-Skia) shape standard elements.
ColoredCircle, RoundedRectangle, and Arc - Skia standard elements.
Line supports Has Dropshadow and Use Gradient, but not Is Filled (a line draws as a stroke and has no fill).
Skia standard elements are a collection of elements which use SkiaSharp for rendering. Skia standard elements provide additional types of visuals supported by Gum, but not all runtimes support Skia standard elements.
Skia adds advanced vector graphics support, including the Arc shape and vector file formats such as SVG and Lottie.
Using Skia Standard Elements may limit which platforms can run your Gum project. For more information, see the Shapes Platform Support page.
Skia standard elements must be explicitly added to gum projects. To add Skia standard elements Select Plugins -> Add Skia Standard Elements.

After clicking this option, Gum adds new standard elements.

Once these Skia standard elements are added, they can be added to Screens and Components just like any other standard element.

The Texture Top variable controls the top pixel of the source rectangle used to draw the NineSlice. Texture Top is only available if the NineSlice uses a Texture Address of Custom or Dimension Based.
The following image shows a NineSlice with a Texture Top value of 48.

Texture Top controls the top side of the region that the NineSlice displays on its source file. In this case, the top-edge of the source rectangle is 48 pixels from the top edge of the entire file.

RoundedRectangle is being phased out. Use the Rectangle standard element instead and set its Corner Radius — Rectangle now supports rounded corners along with fill, outline, gradients, drop shadows, and dashed strokes on all platforms. RoundedRectangle remains available so existing projects keep working, but it will be removed in a future release.
RoundedRectangle is similar to a ColoredRectangle with the added functionality of supporting rounded corners.

RoundedRectangles also support shape properties such as Has Dropshadow, Is Filled, and Use Gradient. For more information and examples, see the Shape Properties pages.
The Corner Radius variable controls the radius of each of the four corners on a rounded rectangle. A value of 0 results in a sharp corner. Increasing this value makes the corners more rounded.

Corner Radius is restricted to half of the smallest absolute dimension. In other words, if the RoundedRectangle is too small to fit its set CornerRadius, then the effective CornerRadius shrinks.
The following shows a RoundedRectangle with a Corner Radius of 60. If it is resized to have an effective width or height of less than 120, then the effective radius shrinks.

Similarly, setting a Corner Radius that is larger than half the Width or Height does not affect the RoundedRectangle.

Start Angle defines the angle of the starting point of the arc. This value is measured in degrees, with a value of 0 pointing to the right. The value increases counterclockwise. the Start Angle and Sweep Angle values combine to determine the range of angles covered by the Arc.
The following image shows the an Arc with a Start Angle of 0. The red lines and text are not part of the arc and are added to the screen shot to show the location of the Start Angle.

Changing the Start Angle moves one side of the arc. The arc appears to rotate if the Start Angle is changed gradually.

Start Angle defines the starting point of the arc. A value of 270 degrees and a value of -90 place the starting point of the arc in the same location. Values larger than 360 result in the value looping. These values, although normally not needed, can be used to create spinning animatoins.

Gum is the best Game UI Layout tool available. It provides a flexible, efficient layout engine capable of producing virtually any layout. Gum can be used in a variety of contexts including in the FlatRedBall game engine, MonoGame, raylib, Silk.NET, and more. Gum can also be rendered on Skia so it can be used in any environment that supports Skia such as WPF and Avalonia.
The Gum layout engine can also be included in any .NET project without requiring the use of a particular graphical API.
To download the Gum UI tool and start building your UI, see the Setup page.
Gum UI includes advanced layout functionality to create and preview your UI

Gum allows the creation of components which can be instanced and customized in screens and other components

Adjust an object’s origin, position units, size units, and stacking to create fluid UI

Grab the NuGet, add a few lines of code, see your Gum project in game! You can use Gum with MonoGame, KNI, FNA, raylib, Silk.NET, SkiaSharp, and many more platforms. For more information on our runtimes, see the Getting Started page.

Gum objects can be created and modified in code. Create fully-featured UI by subscribing to common UI events.
Gum has been used in commercial projects of all sizes - check them out in our Showcase page.
Gum is actively maintained and provides lots of ways to get answers:
Check the rest of the documentation
Join the Discord chat (shared discord with FlatRedBall)
Create an issue on Github
The ability to expose variables in Gum makes components flexible. For this example we will continue using the HealthBar component from the previous tutorial.
The last tutorial created a HealthBar component with two rectangles - Background and Fill. The instances were set up to be positioned correctly according to the size of the HealthBar.
We also created a GameScreen and added a few HealthBar instances. Although we can position and size each HealthBar instance, they all display the same health percent. This tutorial discusses how to use exposed variables to allow each instance to display a different value.
By default components only exposes top level variables. Variables on instances inside the component are not available when editing an instance. In programming terms these variables are considered protected.
However, we can expose variables inside of our component so that they can be modified in our screen.
To do this:
Select Fill inside the HealthBar component
Find the Width variable in the Variables tab
Right-click on the Width variable Expose Variable
Enter the name HealthPercent for the variable name - note that typically variables are exposed without spaces in them, but Gum will display them with spaces in the variables tab

Notice the variable now displays its exposed variable name.

Although this variable belongs to the Fill instance, it is now exposed as a variable on HealthBar. You can now see this variable by selecting the HealthBar component.

Similarly, now each instance can be modified since each now exposes a Health Percent variable.

This tutorial shows how to use exposed variables to customize component instances. You can expose other instance variables in your components to customize instances. Other examples of variables which may be exposed include:
Visibility of icons on a Button component
Font sizes on a Label component
Sprite visibility showing the number of connected gamepads on a JoinGame component
It's best to experiment with exposed variables to get a feel for how you can use them in your own components.
Gum supports creating and previewing animations in the editor through the use of states. The general workflow for creating an animation is as follows:
Create states representing the keyframes in the animation (usually one category per animation)
Add an animation to the component or screen
Add states to the animation and adjust their time
Set interpolation values for each keyframe to control "easing"
Gum's animation system is very powerful and can be used in a variety of situations:
Animations which play when a screen or component is shown or hidden
Animations used to transition between behavior states such as changing a button from regular to highlighted state
Lengthy animations which can last multiple seconds for complex transitions
Animations are stored separate from the screen or component on the file system. If a screen or component contains at least one animation then Gum will save a Gum Animation file (.ganj or .ganx extension) with the word "Animations" appended on the screen or component's name. In other words GameScreen would have a file called GameScreenAnimations.ganj/ganx in the same folder containing information about its animations.
Once an animation has been made it can be played back in editor. The following shows how an animation is played back, both in real time and also by dragging the slider.

The concept of padding is often used to add spacing between the edge of a container and its children. Padding can be achieved by adding sub-containers.
First we'll create a top-level container. This container controls the size of all objects internally, including the background. We will also include a background object which is sized according to the container. To keep things simple, this example uses a dark blue ColoredRectangle.
The ColoredRectangle is set so its size matches its parent.

Next we can add another container to the top-level container. By default this container sits at the top-left of the parent when it is added with a drag+drop.

To have the container fill its parent, but also include padding:
Select the inner container
Click the Alignment tab
Enter the desired padding in the Margin text box
Click the Dock Fill button

This inner container can now be used to hold all children. Note that if you are creating a Component and you want to make this be the default container for children, you may want to set the Default Child Container to this inner container. For more information see the Default Child Container page.
The X Origin variable controls the point which an object is positioned by. By default the X Origin is Left. X Origin is shown visually as a white "X" in the editor.

X Origin of LeftThe following image shows a ColoredRectangle with its X Origin set to Left:

The following image shows a ColoredRectangle with its X Origin set to Center:

The following image shows a ColoredRectangle with its X Origin set to Right:

The Clips Children property controls whether children of a component or container can render outside of the bounds of their parent. By default this is false, which means that all children are not clipped (can fully-render) regardless of whether they are within the bounds of their parent or not. Setting this value to true prevents children from rendering outside of the bounds of their parent.

Children outside of the bounds of a container with Clips Children set to true can also be clipped by setting a container's Is Render Target value to true.
The clip region is always axis-aligned, so rotating a container that clips its children leaves the clip region unrotated. To rotate a container and keep its contents clipped, see Rotating and Scaling Clipped Contents.
The Min Height variable sets the minimum height in pixels. This value is applied after all other layout so it can be used to overwrite automatically-assigned height.
By default this value is <NULL> which means there is no Min Height.

Min HeightIf Min Height is assigned (not <NULL>), then the effective height cannot be less than the Min Height value. The following animation shows that height is limited to a Min Height of 100.

Min Height set to 100 limits the ColoredRectangle' heightNotice that the Height variable can still be set to a value smaller than Min Height, but it does not apply visually.
Min Height can also be used if Height Units is set to values other than Absolute. For example, Min Height can be used to limit the height of a ColoredRectangle when Height Units is Relative to Parent.

Min Height of 100The Max Height variable sets the maximum height in pixels. This value is applied after all other layout so it can be used to overwrite automatically-assigned height.
By default this value is <NULL> which means there is no Max Height.

Max HeightIf Max Height is assigned (not <NULL>), then the effective height cannot be larger than the Max Height value. The following animation shows that height is limited to a Max Height of 100.

Max Height set to 100 limits the ColoredRectangle's heightNotice that the Height variable can still be set to a value larger than the Max Height, but it does not apply visually.
Max Height can also be used if Height Units is set to values other than Absolute. For example, Max Height can be used to limit the height of a ColoredRectangle when Height Units is Relative to Parent.

Max Height of 100Note that Max Height can prevent a container from growing according to its children. For more information, see the Relative to Children Height Units page.
The Max Width variable sets the maximum width in pixels. The value is applied after all other layout so it can be used to overwrite automatically-assigned width.
By default this value is <NULL> which means there is no Max Width.

Max WidthIf Max Width is assigned (not <NULL>), then the effective width cannot be larger than the Max Width value. The following animation shows that width is limited to a Max Width of 100.

Max Width set to 100 limits the ColoredRectangle's widthNotice that the Width variable can still be set to a value larger than Max Width, but it does not apply visually.
Max Width can also be used if Width Units is set to values other than Absolute. For example, Max Width can be used to limit the width of a ColoredRectangle when Width Units is Relative to Parent.

Max Width of 100Note that Max Width can prevent a container from growing according to its children. For more information, see the Relative to Children Width Units page.
Rotation can be used to rotate Gum components. Rotation is measured in degrees, where positive values rotate an object counterclockwise about its origin (X Origin and Y Origin).
An object is rotated about its origin, which by default is its top-left corner:

Objects can also be rotated visually by grabbing the rotation handle:

Holding the SHIFT key snaps angles to 15 degree increments.

The X Origin and Y Origin properties define the point of rotation for an object. The following animation shows how changing origin values can affect rotation.

Circles can be drawn as an outline, filled in, or both, and supports additional effects such as gradients, drop shadows, and dashed strokes. Circles are sized using their Width and Height values.

Circles support all shape properties. For more information see the Shape Properties page and subpages.

Contained Type enables code generation and Gum runtimes (such as FlatRedBall) to create strongly-typed containers.
Some Gum components or Containers may exist to hold a list of a particular type of item. For example, consider a game which includes a row of hearts to show the player's current health.

In this particular case, the hearts can be filled or empty to show the current and max health, but the max health can also be increased. If the max health increases, then a new heart instance is added to the container at runtime.
Since this container should only ever contain instances of a Heart component, then the container's Contained Type can be set to Heart.

In this example, FlatRedBall respects the Contained Type variable and generates a generic list.

As mentioned above, the implementation of this variable depends on the runtime you are using. If you are using a runtime which does not implement this feature and you would like to have it added, please create a GitHub issue or make a request in Discord.
Containers are used to group objects to simply movement, alignment, positioning, and size. Containers are usually invisible, although they can draw their outlines in Gum to help visualize their position and size.

The Is Tiling Middle Sections property controls whether the non-corner sections of a NineSlice are tiled (repeated) instead of stretched. By default this value is false, meaning the middle sections stretch to fill the available space. When set to true, the middle sections repeat their texture at its natural size instead of stretching.
This property appears in the Source category in the Variables tab.
This is useful for textures with repeating patterns like brick walls, chains, or borders where stretching would distort the pattern.

By default, when a NineSlice is resized, the five non-corner sections (Top, Bottom, Left, Right, and Center) are stretched to fill the space between the corners. This works well for smooth or gradient textures, but can create visible distortion with patterned textures.
When Is Tiling Middle Sections is set to true, the five non-corner sections repeat their texture instead of stretching:
Top and Bottom edges tile horizontally
Left and Right edges tile vertically
Center section tiles in both directions
The four corner sections (Top Left, Top Right, Bottom Left, Bottom Right) are never tiled — they always render at their natural size regardless of this setting.
ColoredRectangle is being phased out. Use the Rectangle standard element instead — Rectangle covers the same solid-color fill (through its Fill Color) plus an outline, gradients, drop shadows, dashed strokes, and rounded corners. New projects seed Rectangle rather than ColoredRectangle. ColoredRectangle remains available so existing projects keep working, but it will be removed in a future release.
ColoredRectangles are used to display solid color rectangles. It can be used to provide a solid colored background or placeholders for content such as Sprites. ColoredRectangles are also useful for quickly blocking out a UI or learning about Gum's layout with a visual object.
As the name suggests, ColoredRectangles have a Color property which can be modified.

The Canvas element creates an instance of a SKCanvas which can be accessed in code to perform custom rendering. The contents of the Canvas cannot be modified in Gum. Since it is a Gum object, it does provide all of the variables for positioning, sizing but the rendering must be performed in custom code.
Since the Canvas cannot perform any rendering in Gum, it appears as an empty container.

Sweep Angle defines the angle that the arc covers. This is a signed value, with positive values going counterclockwise.
The following shows an arc with a positive Sweep Angle of 135 degrees.

Changing the Sweep Angle changes the length of the arc. If the value is negative, then the Sweep Angle increases the size clockwise.

A sweep angle of 360 creates an arc that extends to a full circle. Values greater than 360 appear the same as if Sweep Angle is set to 360.

Rectangles can be drawn as an outline, filled in, or both, and supports additional effects such as gradients, drop shadows, and dashed strokes.

Rectangles support all shape properties. For more information see the Shape Properties page and subpages.

Thickness controls the width of the arc line in pixels. This value can be increased to make the line arc thicker.

Thickness can be increased to create a wedge.

Note that Thickness can be increased to any value including values larger than the radius of the arc. Large values can result in the arc rendering past its center point creating a bowtie shape.

Other undesirable rendering effects can happen with large thicknesses when working with arcs which have one size (width or height) larger than the other, as shown in the following image:

Arcs are curved lines with variable thickness. Arcs can also be used to draw wedges if the line thickness is large enough.

Arcs draw inside their bounds, with the edge of the arc touching the bounding rectangle. The thickness of the arc remains consisntent regardless of the bound width and height.
The following shows an arc with a Sweep Angle of 270 degrees, being resized in the Editor tab.

Svgs can display .svg files. Since these files are vector art, they can be resized without pixelation.
The following is an Svg instance displaying the FlatRedBall logo. Source SVG: https://github.com/flatredball/FlatRedBallMedia/blob/master/FlatRedBall%20Logos/frb-logo-main.svg

The Source File variable controls the lottie animation displayed. This value can be set and changed just like source files on other elements such as a .png on a Sprite.
Width and Height values can be set on an Svg file just any other Gum element. Unlike rasterized objects such as Sprites, Svgs use Vector art so they can be resized and still retain crisp edges and details.

Svgs are still rasterized in Gum, so they display pixels when the view is zoomed in, especially if the Svg has a small Width or Height.

Svgs support the Maintain File Aspect Ratio Width and Maintain File Aspect Ratio Height units. For more information, see the Width Units and Height Units page.
ColoredCircle is being phased out. Use the Circle standard element instead — Circle now supports fill, outline, gradients, drop shadows, and dashed strokes on all platforms. ColoredCircle remains available so existing projects keep working, but it will be removed in a future release.
ColoredCircle are round shapes which can be filled in or drawn as an outline, with options for customizing their appearance.

ColoredCircles support shape properties such as Has Dropshadow, Is Filled, and Use Gradient. For more information and examples, see the Shape Properties pages.
The Texture Left variable controls the left pixel of the source rectangle used to draw the NineSlice. Texture Left is only available if the NineSlice uses a Texture Address of Custom or Dimension Based.
The following image shows a NineSlice with a Texture Left value of 96.

Texture Left controls the left side of the region that the NineSlice displays on its source file. In this case, the left-edge of the source rectangle is 96 pixels from the left edge of the entire file.

Shapes (Skia) support varies per platform. See below to see information about your platform.
MonoGame and KNI projects can use the following shapes:
Arc
Circle
Rectangle
The outline (stroke) of Circle and Rectangle, and Rectangle's fill (at square corners), render out of the box. Circle's fill, Rectangle's rounded corners, and the richer effects (gradients, drop shadows, and dashed strokes) are provided by the shape support package (Gum.Shapes.MonoGame or Gum.Shapes.KNI). Without the package those properties are saved but do not draw.
Other types, such as SVG or Lottie, are not currently supported.
For information on adding the shape support package to your project, see the Shapes page.
FNA renders the outline (stroke) of Circle and Rectangle, and Rectangle's fill (at square corners), out of the box. Circle's fill, Rectangle's rounded corners, and the richer effects (gradients, drop shadows, dashed strokes) are not available on FNA because there is no shape support package for it. We are looking for contributors to help expand FNA shape support.
Raylib supports Circle and Rectangle natively, including fill, gradients, and drop shadows, with no extra package required.
All shape types are fully supported.
var button = new Button();
button.Text = "Hello";
StackLayoutInstance.AddChild(button);void CustomInitialize()
{
MyButton.Click += HandleOkButtonClick;
}
private void HandleOkButtonClick(object sender, EventArgs args)
{
// do your logic here
}Gum runs natively on Windows, macOS, and Linux — no WINE or other compatibility layer needed. It opens the same projects, saves the same files, and generates the same code on every OS.
Download the latest release directly: https://github.com/vchelaru/Gum/releases/latest
Release history (including older releases): https://github.com/vchelaru/Gum/releases
Gum Source Code: https://www.github.com/vchelaru/Gum
Each release lists these files:
Gum-win-x64.zip
Windows (64-bit)
Gum-osx-arm64.tar.xz
macOS on Apple Silicon (M1 and later)
Gum-osx-x64.tar.xz
macOS on Intel
Gum-linux-x64.tar.xz
Linux (64-bit)
Each download includes everything it needs, so you do not need to install .NET first. A matching .sha256 file lists the checksum of each download.
Unzip Gum-win-x64.zip into a folder of your choice.
Run Gum.Avalonia.exe.
Gum is not signed, so Windows shows the "Windows protected your PC" popup the first time. Click More info, then Run anyway. Alternatively, right-click the .zip file and select the option to unblock it before extracting.
Double-click the .tar.xz file for your Mac to extract Gum.app.
Move Gum.app into your Applications folder.
Open a terminal and allow the app to run. Gum is not notarized by Apple, so macOS blocks it until you do this once:
xattr -dr com.apple.quarantine /Applications/Gum.appOpen Gum from Applications or Launchpad.
Extract the download into a folder of your choice:
mkdir -p ~/gum && tar -xJfRun Gum:
~/gum/Gum.AvaloniaGum needs a desktop session (X11 or Wayland), a graphics driver with OpenGL 3.0 or newer, and the fontconfig library (libfontconfig1 on Debian and Ubuntu), which desktop installs normally include.
Releases up to and including September 2, 2026 are the older Windows-only WPF tool, distributed as Gum.zip with Gum.exe inside. That release stays downloadable if you need it, for example for a plugin that has not been migrated yet (see Plugins), but it does not receive new features. Its WINE setup scripts for Linux and macOS are kept at that release's tag (setup_gum_linux.sh, setup_gum_mac.sh); the native downloads above replace them.
Plugins built only for the older WPF tool do not load. The Plugins dialog lists them as not supported. See Plugins for how to migrate one.
The command-line tool (gumcli) is included in the GumCli folder beside the tool, but only the tool's own Export as SVG uses it so far.
Gum is not signed on Windows or notarized on macOS, which is why the steps above are needed.
Please report anything else you find on the Gum GitHub issues page, along with your operating system.
Austerity X
Deadvivors
Cranky Chibi Cthulhu
TerraScriber
Champions of Anteria
Tetris Blitz
Tula Mobile App
Catnip Coast
War Haven
BattleCrypt Bombers
Teotihuacan
Ship Skwabble
Gum supports loading image files for Sprites and NineSlices. This tutorial discusses how to load files, and how they are referenced in Gum.
First we'll set up a workspace:
Create a Screen called SpriteScreen.
Drag+drop a Sprite into the newly-created Screen

Source File is the image that the Sprite displays. Usually Source Files are of the .png file format. To set the source file:
Select SpriteInstance
Find Source File in the Variables tab
Click the "..." button to bring up a file window
Navigate to the location of the file you would like to load
Click "Open" in the file window
Once Source File is set, the Sprite displays the image in the Editor tab

If you select a file which is not located in the same folder or a sub folder of your gum project, Gum asks if you would like to reference the file in its original location or create a copy.

Usually it's best to copy the file to the Gum project folder so that the Gum project can be moved to different computers without breaking file references.
Sprites can display portions of their Source File. Files which combine multiple images are often called sprite sheets or tile sheets, and are commonly used in game development to keep art organized and to improve performance.
For example, the following file contains images for an animated character, ground tiles, and other entities for a platformer game.
If we download this file and set it as our , then the sprite displays the entire file.

We can display a portion of the Sprite rather than the entire file:
Click on the Texture Coordinates tab
Check the Snap to grid option to make it easier to select a region
Double-click anywhere on the image to select a region around the cursor
Move the selected region to the desired location to adjust the sprite's texture coordinate values

Bottom-up stacks can be used to display stacks of elements which should move up as more are added. This concept is similar to messages received in a chat window. Gum layout can be used to produce this type of stack.
Items in a bottom-up stack need a parent Container. This Container could be an instance of a Container or a component since components usually have their Base Type set to Container. For this example we'll use a container.

This container to stack needs the following variables set:
Children Layout set to Top to Bottom Stack so all children stack vertically
Children Layout set to Top to Bottom StackHeight Units set to Relative to Children so the container resizes itself as more children are added
Height Units set to Relative to ChildrenHeight set to 0 so the effective height of the container is based purely on its children
Height set to 0Stack Spacing set to 2 (optional) to add spacing between each child
Stack Spacing set to 2Now children of the Container stack vertically. This concept works for any type of child, but we'll use ColoredRectangles for this example. Add a few instances to the Container and they stack vertically.
Finally we can have the stack grow up instead of down. To do this, change the following variables on the parent container:
Y Origin set to Bottom
Y Origin set to BottomY Units set to Pixels from Bottom
Y Units set to Pixels from BottomNow as new children are added, the parent stack grows and all items shift up.
Gum provides simple controls for centering objects inside of their parents. This page shows how to center objects in a variety of situations. For brevity this document uses vertical centering, but the same concepts apply to horizontal centering.
The easiest way to center an object is to use the center Anchor. This sets all of the values necessary to center an object both vertically and horizontally.

Objects can be centered by setting their unit and numerical values. The Alignment tab is a shortcut for these values, but we can assign each value individually so an object is centered vertically:
Set Y to 0
Set Y Units to Pixels from Center
Set Y Origin to Center
Y, Y Units, and Y OriginCentering can be performed with margins by adding an additional container to create the necessary margins. For example, consider a situation where we want to center the green rectangle inside the blue rectangle, but leave a 32 pixel margin at the top.
We may want something similar to the following image:
To do this, an additional container can be added as shown in the following image:
In this case, the container has the following relevant properties:
Y = 0 (so it is pressed against the bottom)
Y Units = Pixels From Bottom (so it is bottom justified)
Height = -32 (leaving a 32 pixel margin)
Height Units = Relative to Parent (so that it always has a 32 pixel margin regardless of parent size)
The green rectangle can be added as a child to the container, and then centered within the container. This results in the green rectangle always being centered within the area that leaves a 32 pixel margin at the top even if the main rectangle is resized, as shown in the following animation:
Additional margin can also be added to the bottom by changing the container's Y value. For example, a 20 margin border can be added at the bottom, leaving a 32 pixel margin at the top by setting the following values on the container:
Y = -20 (move the bottom of the container up by 20 pixels)
Height = -52 (leaving a 32 pixel margin at the top, and accounting for the container being moved up an extra 20 pixels)
Stacks can be centered horizontally or vertically. To center a stack of objects, an internal container is needed.
A centered stack might look like this:
For this example, we'll begin with a Container and a background ColoredRectangle. The background is not necessary, but it helps visualize the main Container's size.
Next we'll add another container which will hold our stacking instances.
Drag+drop a container onto the MainContainer
Click the Alignment tab
Click Anchor Center
We can add children to the container:
Set the inner container's Children Layout to Top to Bottom Stack
Drag+drop children onto the inner container to have them stack
Optionally adjust the Stack Spacing variable to add gaps between the children
Optionally adjust the children such as changing their size or color
For this example I modified each child rectangle to have
Width = 128
Height = 32
Color = Green
Finally, we mark the inner container to be sized according to its children. Since it remains centered, whenever its size adjusts (by adding or removing children), the inner container adjusts to remain centered.
Now if children are added or removed, the container remains centered.
Alpha controls an instance's transparency. A fully opaque instance has an Alpha of 255. A fully transparent instance has an Alpha of 0.

An object's transparency is a combination of its Alpha, Blend, and its Source File. Shapes may also have transparent portions due to their form (such as ColoredCircle and RoundedRectangle) as well as dropshadows.
By default the Alpha property affects the selected instance only - it does not cascade down to its children. For example, the following shows a parent white ColoredRectangle with a child blue ColoredRectangle. If the white ColoredRectangle's Alpha property changes, the BlueRectangle's opacity does not change.
A parent can affect its children's transparency if the parent is a container with Is Render Target set to true. For example, if the white rectangle is added to a Container, the Container can make its entire contents transparent.
Note that by setting Is Render Target to true, the entire container's Alpha can be adjusted rather rather than the alpha value cascading to each individual child. This Alpha value is used to control transparency after all children have been drawn. We can see the difference between a partially-transparent Container and each child individually being made partially transparent by overlapping two children ColoredRectangles.
The rectangles on the left each have an Alpha value of 255. These rectangles are in a Container Is Render Target set to true and an Alpha set to 128.
The rectangles on the right each have an Alpha of 128, so the red rectangle is visible behind the blue rectangle.
By default, when one instance (such as a NineSlice) is attached to another instance (such as a Container), the child attaches to the root of the parent. However, complex components often have internal structures. For example, a Window may have an InnerPanel which acts as the "landing zone" for children.
Slots allow you to designate specific internal parts of a component as an "attachment point". Any instance in a component can be designated as a slot by checking the Is Slot variable.
Note that instances can be marked as Default Slots for automatic parenting. For more information see the Default Slot page.
Setting an instance's Is Slot to true is a way to tell Gum that it should be available as a parent. Any number of instances can be slots.
For example, consider a Component with three children: Header, Body, and Footer. In this case all three instances should be considered slots.
To set the value, select each instance and check Is Slot.
If we have an instance of this HeaderBodyFooterComponent in a screen, then other instances can use any of the slots as their parent value. For example, the following screenshot shows a Text instance's available parents. Notice that all three slots are available.
We can select any of these as the Text's parent.
The behavior of the Locked property is changing for the February 2025 release of Gum as outlined in this issue: https://github.com/vchelaru/Gum/issues/273
Previous versions allowed locked items to be edited once selected, but they only prevented selection in the Editor tab.
The Locked property controls whether an instance can be clicked in the Editor tab, and whether any variables can be modified on the locked item.
Locked items appear with a lock icon.

If this value is true, then the following is true:
Instance cannot be selected in the Editor tab
Instance variables are all disabled and cannot be edited in the Variables tab (except un-locking the instance)
Selected instances cannot be moved, resized, or rotated in the Editor tab
Polygons cannot have points modified, added, or deleted in the Editor tab
Locked instances cannot be selected by clicking on them in the editor windowThe Min Width variable sets the minimum width in pixels. The value is applied after all other layout so it can be used to overwrite automatically-assigned width.
By default this value is <NULL> which means there is no Min Width.

If Min Width is assigned (not <NULL>), then the effective width cannot be smaller than the Min Width value. The following animation shows that the width is limited to a Min Width of 100.
Notice that the Width variable can still be set to a value smaller than Min Width, but it does not apply visually.
Min Width can also be used if Width Units is set to values other than Absolute. For example, Min Width can be used to limit the width of a ColoredRectangle when Width Units is Relative to Parent.
Min Width of 100Children in a Screen, Component, or parent instance are drawn top-to-bottom, so that children further down are drawn on top.

Gum provides a number of ways to reorder instances.
Items can be right-clicked in the editor to change their order.
Bring to Front - reorders the instance so that it is in front of all of its siblings.
Move Forward - moves the instance in front of the sibling that is in front of it. In other words, moves the item forward by one index.
Move In Front Of - moves the instance in front of the selected sibling.
Move Backward - moves the instance behind the sibling that is currently behind it. In other words, moves the item backwards by one index.
Send to Back - reorders the instance so that it is behind all of its siblings.
Items can be re-ordered in the Project tree view by holding the alt key and pressing up or down.
Gum uses a hierarchical ordering which means that a parent and all of its children draw before any of the siblings of the parent. For example, a container and all of its children draw before any other siblings of the container.
The following animation shows a container named ContainerInstance2 which draws on top of ContainerInstance1. All children of ContainerInstance2 also draw on top of children of ContainerInstance1.
If a parent is reordered, then all of its children also respect the new order. For example, if ContainerInstance2 is sent to the back, then all of its children draw below ContainerInstance1 and its children.
If a parent uses a stack or grid layout for its Children Layout variable, then the order of the children in the Project tab determines their order in the stack or grid.
For more information, see the Children Layout page.
The Visible variable controls whether an object and its children appear.
Setting Visible to false hides the selected instance.

Setting a parent's Visible variable to false also hides all children. Note that this does not explicitly set the Visible property to false for all children, but a child's effective visibility depends on its parent.

If an instance is part of a parent which stacks its children (has a Children Layout of Left to Right Stack or Top to Bottom Stack), then it will no longer be considered when stacking siblings if it is invisible. In other words, making an item invisible removes it from the stack.
If the stack contains children which use a Width Units of Ratio, then hiding any of the siblings results in the children with ratio width adjusting to occupy the extra space.
Width Units of Ratio.An invisible object can be selected by clicking on it in the Project tab or in the Editor tab.
Visible items are given preferential selection even if they are ordered behind invisible items.
The X Units variable controls how a unit is horizontally positioned relative to its parent. By default an object is positioned relative to the left of its parent, where each unit represents 1 pixel.
The following shows a child ColoredRectangle positioned 50 Pixels From Left relative to its parent:

The following shows a child ColoredRectangle positioned 50 Pixels From Center relative to its parent:

The following shows a child ColoredRectangle positioned 50 Pixels From Right relative to its Parent:

The following shows a child ColoredRectangle positioned 50 Percentage Parent Width relative to its Parent. In other words, it will be positioned halfway between the left and right edges of the Parent:
The Y Origin variable controls the point which an object is positioned by. By default the Y Origin is Top. The Y Origin is shown visually as a white "X" in the editor.
The following image shows a ColoredRectangle with its Y Origin set to Top:

The following image shows a ColoredRectangle with its Y Origin set to Center:

The following image shows a ColoredRectangle with its Y Origin set to Bottom:

The following shows a Text with its Y Origin set to Baseline:
Baseline refers to the bottom of the text for letters without descenders. For more information see the Wikipedia Baseline page.
Baseline is often used to align fonts of different sizes. The following image shows two Text instances with different font sizes. Both are positioned by their baseline so their bottoms align properly (ignoring descenders, such as on the letter p and the comma).
By contrast, the following image shows the same Text instances using bottom alignment.
Has Dropshadow controls whether a dropshadow is drawn below a shape. By default this value is false.
The following image shows two Rectangles. The left with Has Dropshadow unchecked, the right with Has Dropshadow checked.

Note that if an instance has a dropshadow, the dropshadow renders outside of the bounds of the instance.

Dropshadows draw as part of the object, so if multiple objects stack, their dropshadows also stack.

Dropshadow Offset X and Dropshadow Offset YDropshadow Offset X and Dropshadow Offset Y control the position of the dropshadow relative to the main body of the instance.
This value can be changed to move the dropshadow, which gives the element a sense of height.
Dropshadow Offset X and Dropshadow Offset Y change the dropshadow positionDropshadow BlurDropshadow Blur controls the dropshadow edge softness. A value of 0 creates a sharp shadow, while a larger value increases blur.
Dropshadow Blur can be adjusted to make a dropshadow more blurryDropshadow AlphaDropshadow Alpha controls the transparency of a dropshadow. A fully-opaque dropshadow has an alpha of 255. This value can be modified to decrease or increase the dropshadow's opacity.
Dropshadow Alpha adjusts the dropshadow transparencyDropshadow ColorDropshadow Color adjusts the dropshadow color independent of the shape's body color. Usually dropshadows are pure black with their transparency adjusted by Dropshadow Alpha, but they can also include other colors if needed.
Is Filled sets whether a shape is filled in or if it is drawn using stroke - another word for outline.

Stroke WidthStroke Width sets the thickness of the stroke (outline). Increasing the value makes the stroke thicker. Note that increasing the stroke brings the stroke inward, so the shape is still bound by its effective width and height.

Stroke Width controls the thickness of the outlineIf a shape element has its Is Filled unchecked, this affects the rendering of gradients and dropshadows.
Gradients only fill the solid parts of a shape, so if a shape has Is Filled set to false, the hollow center of the shape does not show gradient color.
Dropshadows respect the opaque part of the shape, so changing Is Filled also affects the dropshadow.
Is Render Target controls whether all instances contained in this container render directly to the screen (if false), or if they first render to their own dedicated target before rendering to the screen (if true).
Is Render Target defaults to false (unchecked).
Is Render Target enables a number of graphical effects including:
Container Alpha (transparency)
Container Blend
Alpha-only Blend modes on instances contained in the Container
As of February 2025 the Is Render Target variable is considered experimental. You may experience issues when using this as it is being developed. Please report any problems you find through GitHub or on Discord.
Containers with Is Render Target set to true automatically clip their children. This behavior is the same as setting Clips Children to true. This happens because render targets internally create a texture which matches their size. Therefore, any items which are placed outside of the bounds of a render target container are not rendered.
Once a container is rendered to a render target, additional special effects can be applied at runtime. These include:
Scaling
Rotating
Rendering portions using texture coordinates
For a step-by-step tool walkthrough of rotating and scaling a clipped container, see Rotating and Scaling Clipped Contents. For the same pattern in code, see the SpriteRuntime RenderTargetTextureSource documentation.
If you are managing a render target yourself in code instead of using Is Render Target, see Render Targets for the blend-mode setup needed to composite translucent content correctly on MonoGame and raylib.
The Stack Spacing variable controls the additional padding between children when a container uses a Children Layout of either Top to Bottom Stack or Left to Right Stack. Stack Spacing serves as an alternative to adjusting the position of each item in a stack.
A larger Stack Spacing value increases the spacing between each child. By default Stack Spacing is set to 0 which means that no spacing is added between items in a stack.

Changing the stack spacing adds gaps between each child as shown in the following animation.

Stack Spacing can also be a negative value resulting in overlapping children. The items in the following animation are partially transparent to show the overlap.

Stack Spacing can be used for either Top to Bottom or Left to Right Stacking.

Stack Spacing can be used on container instances which stack and wrap their children. As stack spacing increases, the amount of space allocated to each object also increases, resulting in wrapping occurring earlier.
If wrapping occurs, then stack spacing applies spacing between rows and columns as shown the following animation:
The Wraps Children property controls whether children wrap or stack beyond their container's boundaries when the container's Children Layout is set to Top to Bottom Stack or Left to Right Stack.

If a parent has Wraps children set to true, the wrapping adjusts in response to resizing the parent.

Similarly, resizing a child may result in the stacking changing.

The row height in a Left to Right Stack is determined by the largest child in the row.

Similarly, column width in a Top to bottom Stack is determined by the largest child in the column.

Wrapping of children can only be performed if the parent's size does not depend on its children (see more info below). If the parent's size does depend on its children, then the parent will expand to fit is children so wrapping will not occur.
If a parent container's Width Units is set to Relative to Children, then it adjusts in response to children size and positioning, so wrapping will not occur.
A parent can use the following Width Units and Height Units with children wrapping:
✅Absolute
✅Percentage of Parent
✅Ratio of Parent
✅Percentage of Width/Height
✅Absolute Multiplied by Font Scale
A parent does not wrap its children if it uses:
❌Relative to Children (see below)
Note that Relative to Children can be used on the non-stacking axis. For example, if a parent uses Left to Right Stack, then it can still have its Height Units set to Relative to Children.
If a container has a non-null Max Width, then it will expand according to its children until it reaches its max width. Once it reaches a max width, it wraps its children.
The following animation shows a container which has:
Width Units of Relative to Children
Max Width of 400
Children Layout of Left to Right Stack
Wraps Children set to True
The Custom Frame Texture Coordinate Width property allows a NineSlice to customize the number of pixels used on the source texture when defining its outer frame. This allows for fine control over which parts of a NineSlice stretch and which parts are used as the corners and edges.
By default this value is null, which means the NineSlice automatically dedicates 1/3 of the texture for the edges.

If the Custom Frame Texture Coordinate Width value is changed, then the source texture applies a fixed pixel size to the borders. For example, using the image above, the frame can be changed to 3 so that only the black and white pixels are part of the border.
If Custom Frame Texture Coordinate Width is set to a value of 0, then the NineSlice does not draw a border. In other words, setting this value to 0 results in the NineSlice behaving like a Sprite.
The Texture Address variable can be used to define the area that the NineSlice displays. By default the Texture Address is set to Entire Texture which means the NineSlice will display the entire source file (split up among the nine pieces).
The following screenshot shows an entire texture being used for a NineSlice.

The entire texture is split up into 3 sections horizontally and 3 sections vertically, matching up the texture coordinates used to display the NineSlice's 9 sections.
The Custom value allows specifying a custom set of coordinates for the Nine Slice. Custom is most often used when an image is part of a sprite sheet. The following example uses this image:

The NineSlice uses the following variables:
Texture Address = Custom
Texture Top = 0
Texture Left = 0
Texture Height = 40
Texture Width = 40
These values result in the the following NineSlice:
Polygons can be any shape, so their width and height values cannot be explicitly set. Instead, a Polygon's width and height values are determined by their points.
A Polygon's effective width and height is determined by its points. The furthest-right point determines the polygon's width and the furthest down point determines the polygon's height.
For example, a square Polygon with the furthest points at 128,128 has a width of 128 and a height of 128.

A Polygon's height can be used to affect parents, siblings, and children depending on the other instances' Width Units, Height Units, and stacking values.
For example, we can add a rectangle as a child of a ColoredRectangle to see how its points affect the size of the polygon.
We can see similar behavior if we place the Polygon in a stacking parent.
A Polygon's height and width are measured from a Polygon's top left corner to the furthest down right point. Points which have a negative value do not affect a Polygon's effective height, so moving points above or to the left of the origin will not affect the layout of any object which depends on the Polygon's size.
For example, if we move Polygon points in a stack up or to the left, this does not shift any of the Polygon's siblings.
This guide walks through Gum's layout system using Figma as a reference point. The quick reference table below covers the most common mappings. The sections that follow explain the concepts that feel meaningfully different coming from Figma.
Page
(no equivalent — Screens serve as the organizational unit)
In Figma, you organize your work into Pages, each containing Frames that typically represent individual screens or views. Components live alongside your frames and can be used across pages.
Gum splits this into three explicit categories visible in the Project panel:
Screens — represent individual UI states in your game, like a main menu, HUD, or pause screen. You can think of each Screen as a top-level Frame in Figma. Unlike Figma frames though, Screens can't be nested inside other Screens — they're always top-level.
Components — reusable elements like buttons, list items, or windows. These work like Figma components: define once, place instances anywhere.
Standard Elements — the built-in primitives (Sprite, Text, ColoredRectangle, etc.) that you drag into Screens and Components to build your UI.
There's no equivalent to Figma's Pages — Screens serve as the organizational unit directly.
Gum's coordinate system works the same as Figma's: X increases to the right, Y increases downward, with (0, 0) at the top-left of the canvas or parent.
In Figma, a Frame can hold children and have its own fill and stroke. In Gum, layout containers are called Containers, and they are always invisible — there's no fill or stroke to set. You may notice containers showing up with a dotted outline in the editor, but that's just the container outline display (on by default in Gum) and isn't part of the rendered output.
To give a container a visible background, add a ColoredRectangle or NineSlice as a child. For example, a button component might have a Container at the root, a NineSlice child for the background, and a Text child for the label.
In Figma, you set X and Y and use the nine-point reference selector to control which corner of the object those numbers measure from. In Gum, the same idea is split into three properties:
X Units options:
Y Units mirrors this vertically, with positive Y always pointing downward. Pixels From Right and Pixels From Bottom work the same way — X=0 / Y=0 is at the edge, and positive goes outward past it. To position something inside those edges, use negative values.
X Origin / Y Origin options are Left/Top (default), Center, and Right/Bottom — the same as Figma's nine-point reference selector, just set separately per axis.
Center an element horizontally inside its parent (like Figma's "center" horizontal constraint):
Pin an element's right edge 10px inside the parent's right edge (like Figma's right constraint with 10px offset):
Note that Gum doesn't pin both sides of an element at once to stretch it. Stretching is handled by Width/Height Units instead.
Like Figma's Fixed / Fill / Hug, Gum controls sizing through Width Units and Height Units:
Relative to Children works like Hug. The numeric value adds padding — for example, Width = 16 with Relative to Children adds 8px on each side. Note that children whose size depends on the parent's size are excluded from this calculation to avoid a circular dependency.
Ratio of Parent works like CSS flex-grow. Three siblings with ratios of 1, 2, 1 get 25%, 50%, and 25% of the parent's width respectively.
The Alignment tab has shortcut buttons that set X, Y, Width, and Height variables for common layouts. They don't toggle any state — they just write variables, so you undo them with Ctrl+Z.
Anchor sets position variables only (X, Y, and their Units and Origins), similar to Figma's constraint presets. It won't change the element's size.
Dock sets both position and size, for "fill a side" patterns — think of it as Figma's "Fill container" combined with a constraint. Options include Top, Bottom, Left, Right, Fill, Fill Horizontally, Fill Vertically, and Size to Children.
Figma's Auto Layout is called Children Layout in Gum, set on the container itself:
Stack Spacing is the same as Figma's Gap between items. Negative values cause children to overlap.
In Auto Grid modes, the parent's size is divided equally among cells. The number of columns (or rows) is fixed; additional rows (or columns) are added as needed.
A couple of differences from Figma's Auto Layout worth knowing:
No padding. To approximate padding, size a child with Relative to Parent and a negative value, or offset children manually.
Cross-axis alignment is per-child. In a Top to Bottom Stack, Gum controls each child's Y automatically, but each child sets its own X. In Figma, alignment (left/center/right) is a single setting on the parent.
Wraps Children works like Figma Auto Layout's Wrap mode. Row height is set by the tallest child; column width by the widest.
One constraint: the container's size on the stacking axis can't be Relative to Children at the same time — that would be circular. You can still use Relative to Children on the cross axis (e.g. height on a horizontal stack). Alternatively, set a Max Width on the container — it will grow with its content until hitting the max, then start wrapping.
Figma's Clip content is called Clips Children in Gum. Off by default, meaning children can render freely outside their parent's bounds.
Gum's Components work like Figma's components — define once, place multiple instances, override individual properties per instance.
Gum also has Is Slot, which doesn't have a direct Figma equivalent. You can mark child instances inside a component as slots — named attachment points that elements can parent themselves to when the component is placed in a screen. For example, a Window component with Header, Body, and Footer slots lets you drop children directly into any of those sections.
Same as Figma: items earlier in the tree render behind items later in the tree. Right-click to Bring to Front, Send to Back, Move Forward, or Move Backward. Reordering a parent moves all its children with it.
Rotation is in degrees. One difference from Figma: positive values rotate counterclockwise (Figma rotates clockwise). The pivot point is set by X Origin and Y Origin — by default that's the top-left corner, so set both to Center if you want to rotate around the middle.
Min Width, Max Width, Min Height, and Max Height work the same as in Figma — they clamp the effective size after all other calculations. They work with any Width/Height unit type, so you can combine them with Relative to Parent or Relative to Children layouts.
States allow you to set multiple variables at one time. Examples of states might include:
A button with Regular, Highlighted, Pressed, and Disabled states
A game logo in Large and Small modes
A game HUD which can appear on and off screen
This tutorial shows how to add states which can be used to display if a player is low, medium, or high health by adjusting the color of the fill bar.
This tutorial builds upon the previous tutorials where a HealthBar component was created. If you haven't yet, you should read through the earlier tutorials to create a HealthBar component.
First we'll define a category and our three states. All components and screens have a Default state automatically. This Default state is uncategorized, but all other states must be in a category. Therefore, we'll first add a new category:
Right-click in the States tab
Select Add Category
Enter the name HealthCategory
Although it's not necessary, categories often have the name "Category" at the end.
To add a new state:
Right-click on HealthCategory
Select Add State
Enter the name "High"
Click OK
The HealthBar component should now have three states.
Once a state is defined and selected, you can make changes to the component and any of those changes are applied to the selected state. In other words, any variable that is set when the High state is selected results in that variable being added to that state.
For this component, we want to change the Fill color depending on whether the health is High, Medium, or Low.
Our High state should display a green color, and if you've set your Fill to be green, then this is already set how we want. This means we don't have to make any changes to the High state.
Instead, we'll make the fill yellow in the Medium state:
Select the Medium state
Select the Fill Rectangle instance under HealthBar
Change the Fill Color variable to a yellow color. Note that the fact that our rectangle is called "Fill" and that we are changing "Fill Color" is a coincidence. We named our Rectangle Fill because it fills the health bar. The Fill Color exists on every Rectangle, and controls the inner color of a rectangle, as opposed to Stroke Color which controls the outline color.
Although this might seem like a simple change, a lot has happened in response to this change, so we should take a moment to break it down.
First, by changing the Fill Color value on the Medium state, we have set every state to explicitly set its color. We can see this by noticing that every state now has an edited icon.
This tells us that the Fill instance is modified by every state in the HealthCategory. Even the High and Low states, which haven't been modified, are now explicitly setting the color to the default green.
We can modify the Low state to be a red color:
Select the Low state
Make sure Fill is still selected
Change the Fill Color variable to a red color
Now we can select any state and see what our state looks like immediately.
Now that we have added a new category to our HealthBar component, we can assign per-instance.
Notice that the Health Category State variable is independent of Health Percent. Although the two are conceptually connected, Gum considers these to be two unrelated variables which can be adjusted individually. These variables would typically be connected in code in a game.
This tutorial covers how to set up a state, but the next tutorial dives deeper into categories, including using multiple categories to mix variable assignments.
This article shows how to create an animated component. It will contain an animation which can be used when the component first appears.
First we'll create a component which will be animated. To do this:
Right-click on Components
Select Add Component
Enter the name TextComponent and click OK
Drag+drop the Text Standard into the TextComponent to create a Text instance
Select the Alignment tab and click the middle button to have the TextInstance fill the TextComponent
Now that we have a component we'll add the states needed for animation. We'll add all states in a category called HideShow. Animation states should always be categorized. To create the states:
Right click in the States list box
Select Add Category
Enter the name HideShow
Right-click on the HideShow folder
Now that we have the states defined we can set values for the states. In this case the only thing we'll be modifying is the TextInstance's Font Scale value. To do this:
Select TextInstance
Select the Hidden state
Set the Font Scale to 0. This makes the Text so small that it's invisible
Select the
The two states we created above will be used as the keyframes for our animation. The animation will begin in the Hidden state then interpolate to the Shown state. To add this animation:
Verify that TextComponent or any objects under it are selected
Select View -> View Animations
The Animations tab appears in the bottom right
The animation can now be played or previewed:
The Interpolation Type value sets how one keyframe blends to another. By default keyframes use Linear interpolation, which is a constant change from one state to another. When interpolating from one keyframe to another, the first keframe defines the interpolation type. In our case the Hidden frame defines the interpolation type. We can change the Interpolation Type and preview the animation:
Select the Hidden keyframe
Change Interpolation Type to Elastic
Playing the animation will reflect these changes.
Gum supports creating animations which can play other animations. This is especially useful when creating animations in Screens that contain components which themselves have animations. This tutorial will build upon the previous tutorial where we created an animated component called TextComponent.
First we'll create a Screen called AnimatedScreen. To do this:
Right-click on Screens
Select "Add Screen"
Enter the name "AnimatedScreen" and click the OK button
Drag+drop a few TextComponents into the Screen and spread them out visually
The animation we will be creating in our Screen will start with all TextComponents being invisible, then each one appearing by playing their Show animation. The animations will be slightly staggered. First we'll add the initial state where all of the TextComponents are invisible. To do this:
Verify that the AnimatedScreen is selected
Right-click in the states area and select "Add Category" name it "ScreenCategory"
Right-click the category and select "Add State"
Name the state "AllInvisible" and click OK
Now we have all of the states and animations that we'll use as keyframes in our animation. To create the animation:
Select AnimatedScreen
Select "View" -> "View Animations"
Click "Add Animation"
Name the animation "ShowAll"
The animation now sets all TextComponents to their Hidden state initially.
Next we'll be adding animations to animate the TextComponent instances to visible. To do this:
Bring up the animation window for AnimatedScreen if it is not already showing
Select "ShowAll"
Click "Add Sub-animation"
Select the first TextComponentInstance
Now the animation can be played or previewed with the slider bar:
The Clips Children and Is Render Target properties clip their children to an axis-aligned rectangle. Because the clip region stays aligned to the screen, rotating a container that clips its children leaves the clip region unrotated, so the result looks broken.
To rotate (or scale) a container and keep its contents clipped, you render the container to a render target and display that render target through a Sprite. The Sprite can then be rotated, scaled, positioned, and stacked like any other Gum object, and the clipping rotates along with it.
This effect uses two objects:
A Container with Is Render Target set to true. This container holds the content you want to clip, and it clips its children automatically.
A Sprite with its Render Target Texture Source set to the container above. The Sprite displays the container's render target and can be freely rotated and scaled.
The source container (which has Use Render Terget set to true) can even be made invisible:
Create a Container and add the children you want to clip and rotate.
Select the Container and set its Is Render Target value to true. Its children are now clipped to the container's bounds.
Create a Sprite.
A container with Is Render Target set to true performs its layout and rendering even when its Visible value is false. Set the source container's Visible to false to hide the original while still displaying it through the Sprite.
Children inside the render target container are not interactive while displayed through the Sprite
— the same pattern in code
The Use Gradient property controls whether a shape uses gradient values if true or a solid color if false.
If this value is set to true, then additional properties appear for controlling the gradient.
A gradient creates a smooth interpolation from a start color to Color2.
For Circle, Rectangle, and Arc, the gradient starts from the shape's own color — for Circle and Rectangle that is the Fill color when the shape is filled or the Stroke color when it is outline-only, and for Arc it is the shape's Color. To adjust where the gradient begins, change that color; to adjust where it ends, change Color2. Because the start is the color the shape already shows, turning Use Gradient on and off does not produce a sudden color change.
The older ColoredCircle and RoundedRectangle shapes instead expose a dedicated Color1 for the gradient start.
The gradient values appear at their respective values at the points specified by Gradient X1, Gradient Y1, Gradient X2, and Gradient Y2. For example the gradient points could be visualized as shown in the following image:
Changing the Gradient X or Y values changes the start and end points for the gradient.
Gradient values use Units similar to X Units and Y Units. By default, gradient values are relative to the top-left of the element. Since the gradient values are not affected by size, changing the size of the element does not affect the gradient.
The gradient X and Y units can be changed. Each value can be set independently. For example, the X2 and Y2 units can be adjusted to be relative to the bottom-right corner of the instance. The following shows a RoundedRectangle with the Gradient X2 and Y2 values 100 pixels up and to the left of the bottom-right corner. If the RoundedRectangle is resized, then the gradient adjusts in response.
Gradient X and Y values can exist outside of the visual space of the instance, and even outside of its bounds. The following image shows an Arc with a gradient which is defined below the visual part of the arc. Notice that the Gradient Y values are both 0 PixelsFromBottom.
Gradient Type controls whether the gradient is linear or radial. Radial gradients place the center of the radial gradient at X1,Y1 and the edge of the radial gradient at X2, Y2.
Default Slot specifies where children are added to instances of the selected component.
By default this value is blank, which means that newly added children treat the entire component as their parent. If Default Slot value is set, children which are dropped on instances of this component type use the Default Slot as their parent.
Default Slot is typically set on containers which are designed to hold children, but which have margins or decoration around the dedicated container instance. Examples include list boxes, tree views, and frames.
Multiple instances can act as slots. For information on using multiple slots, see the Is Slot page.
Consider a Component named Frame which has two instances: OuterRectangle and InnerRectangle.
This Component is designed to keep all of is children inside the InnerRectangle, so that any child automatically respects the margin specified by InnerRectangle.
To make this kind of relationship the default, the Frame can set its Default Slot property to InnerRectangle.
Once this value is set, instances which are drag+dropped onto Frame instances use the InnerRectangle as their parent, as shown in the following animation.
When one instance is drag+dropped onto another instance, the Parent property is set according to the parent's Default Slot.
Using the example above, the RectangleInstance is dropped on the ContainerTestInstance. Since the ContainerTestInstance is of type Frame, then the Default Slot is applied on the drop, which results in the RectangleInstance's Parent being set to ContainerTestInstance.InnerRectangle.
As mentioned above, if an instance is added to a parent component, the instance automatically attaches itself to the parent's Default Slot. This can be undone by manually changing the Parent property.
For example, the Parent can be manually changed to ContainerTestInstance.
Points are an ordered set of X,Y values defining the shape of the polygon. All points are relative to the Polygon's position. Typically the last point is the same as the first point creating a closed polygon.
By default polygons have four sides. Since the first and last point is repeated, a four-sided polygon has five points.
Each point is relative to the polygon's X and Y (position). Points use pixel coordinates. The following image shows a polygon with the following points:
-32, -32
32, -32
32, 32
32, -32
-32, -32 (repeat of first point)
Notice that the image above has points which appear above and to the left of the polygon's origin.
The easiest way to add points is by selecting a Polygon, then clicking on the + icon that appears in the center of the line where you would like to add a point. The following animation shows how to add points to a square to create an octagon:
Points can be moved by clicking on them and dragging them in the editor. Note that points can be positioned anywhere, even if lines cross or if a polygon is concave.
A point can be removed by clicking on it and pressing the delete key.
Each point can be edited in the Variables tab. To edit a point, double-click the desired point and type in the new X,Y value.
Points can also be edited manually in the Screen or Component which contains the Polygon instance. You can open the file in a text editor to see a list of points.
For example, consider the following polygon:
The points for this polygon defined in the MainMenu XML file might look like this:
These points can be changed in the XML file. If the file is changed then Gum automatically reloads this file.
Remember that the first and last points should have the same values if you want your polygon to be closed. You can make edits in the XML file to separate the start and end if you would like to draw a segmented line rather than a closed polygon.
The Y Units variable controls how a unit is vertically positioned relative to its parent. By default an object is positioned relative to the top of its parent, where each unit represents 1 pixel downward.
The following image shows a child ColoredRectangle positioned 50 Pixels From Top relative to its parent:
The following image shows a child ColoredRectangle positioned 50 Pixels From Center relative to its parent:
The following image shows a child ColoredRectangle positioned 50 Pixels From Bottom relative to its parent:
The following image shows a child ColoredRectangle positioned 50 Percentage Parent Height relative to its parent:
Pixels From Baseline positions a child relative to the parent's baseline. If the parent is a Text instance, the baseline is the Y position of the bottom of letters which do not have descenders. For more information on the concept of text baseline, see the baseline Wikipedia page
The following image shows a child ColoredRectangle positioned 0 pixels relative to a Text instance's baseline.
When using Pixels From Baseline, the position depends on the font size, baseline definition in the .fnt, and whether the text wraps. For example, changing the Width of the Text causes line wrapping which shifts the baseline.
A text instance's baseline is defined by its Font and Font Scale values. These values ultimately create a .fnt file with a base value indicating the distance from the top of the text instance to the baseline. For example, an Arial font with Font Size 40 has a base value of 36 and a lineHeight of 45.
This means that 36 pixels fall above the baseline, and 9 pixels (45 - 36) below.
Note that if the parent is not a Text instance, then the bottom of the parent is used as the baseline. The following image shows a Colored Rectangle using a Y Units of Pixels From Baseline with a Container parent.
The Color value is used to perform a multiply color operation on the sprite. Color values can be used to darken or tint a grayscale texture. By default Sprites us a white color, which means the original texture will display unmodified.
The following images show the color values as applied to a multi-color sprite.
Red: 255 Green: 255 Blue: 255
Red: 255 Green: 0 Blue: 0
Red: 0 Green: 255 Blue: 0
Red: 0 Green: 0 Blue: 255
Red: 128 Green: 128 Blue: 128
Red: 0 Green: 0 Blue: 0
NineSlice is a standard component which can be used to create visual objects which can stretch to any size without creating distortion on the source image. For example, consider the following image:
This image could be used to create nine slices of various sizes without any distortion:
The NineSlice achieves this effect by splitting the texture into nine pieces, and scales each one differently to prevent distortion. Highlighting a nine slice shows how it is split:
This is achieved by splitting the texture into 1/3 sections wide and tall. The following image shows how the original image will be split:
The simplest way to assign a texture to a NineSlice is to use a single file. Setting the SourceFile to a single PNG will result in the NineSlice using that one texture, where each section of the NineSlice displays 1/3 of the width of the file and 1/3 of the height of the file.
A NineSlice's Texture Address property can be used to change the portion of the source texture that it uses. More info can be found in the Texture Address subpage.
Alternatively, nine files can be used to specify each section of the NineSlice independently. To use nine individual files, each file must be given a specific suffix.
The following suffixes can be added to create nine slice graphics. For example, assuming your NineSlice image is called "Image" and you are using the .png file format:
Image_BottomCenter.png
Image_BottomLeft.png
Image_BottomRight.png
Image_Center.png
LottieAnimation instances can render animations in the Lottie format. Lottie files are animated files, usually with vector art, which serve as an alternative to gifs. Since they are often vector art, Lottie files can be resized without pixelation.
Lottie files can be downloaded from various sites or created in application such as Adobe After Effects. If you are interested in testing out Lottie animations, you may want to check lottiefiles.com for sample Lottie files.
The following shows a Lottie animation playing in Gum. Source file: https://lottiefiles.com/free-animation/city-skyline-HFnJYQZLPP
The Source File variable controls the lottie animation displayed. This value can be set and changed just like source files on other elements such as a .png on a Sprite.
Width and Height values can be set on a Lottie file just like any other Gum element. Unlike rasterized objects such as Sprites, LottieAnimations use Vector art so they can be resized and still retain crisp edges and details.
LottieAnimations are still rasterized in Gum, so they display pixels when the view is zoomed in, especially if the LottieAnimation has a small Width or Height.
This page walks you through the basics of using the Gum UI tool, which we'll refer to simply as Gum for this and all other documentation.
Gum separates its elements into three categories: Screens, Components, and Standard. Behaviors are an advanced topic that we'll skip for these tutorials.
Standard elements represent the building-blocks for screens and components. Let's take a look at the different types next.
Circle - a circle which can be filled in, outlined, or both. Often used for visualizations or for defining collision in your Gum objects for a game.
The Gum Variables tab displays all available variables when editing an instance or element. The Variables tab exposes all variables, and is useful for making fine changes to instances, such as by moving an instance by a single pixel.
The Variables tab shows variables for the selected instance or element.
Variables can be edited by changing values on the selected variable. For example, to move the text to the right, change its X value to a positive number. Press Enter or Tab to apply the changes:
Gum provides a flexible positioning system. The position of an element is a result of a number of variables. We'll go over a few here.
By default all instances are positioned by their top-left corner. For example, setting the Text instance's X and Y to 0 aligned its top-left position to the top-left of the screen (which is identified by a dotted line.
Components are reusable objects which can contain instances of other components and of standard objects. Examples of components include:
Health Bars
Buttons
Popup Menus
Components can also be simple such as a button or more complex UI elements such as a full Options menu with dozens of instances.
Introduction
The Components tutorial shows how Rectangle instances can be sized and positioned according to the component that they are a part of. Instances can use other instances as their parents too. Gum does not place a limit to the depth of the parent/child hierarchy, enabling flexible and responsive layouts through.
Parent/child relationships are useful for
Automatically adjusting margins and backgrounds
Word-wrapping text relative to a parent
The Parent variable allows UI elements to be positioned and sized according to other UI elements. Parenting hierarchies can go many levels deep and the parent/child relationship can be visualized by the white line connecting the parent to the child when the child is selected.
Parents control control the position of their children. Parents can also control the size of their objects depending on the child's Width Units and Height Units.
For example, if a parent is moved, its children move along with it. For more information on positioning children, see the and pages.
Children can also be sized according to their parents. For more information on sizing children according to their parent, see the and pages.
The Base Type variable can be used to specify both inheritance but also the type of an instance.
Base Type on an instance indicates its type. This is usually automatically set when an instance is first created - usually by drag+dropping a component or standard element onto its target component or screen.
Gum Screens and Components support changing Base Type to specify inheritance. By setting Base Type, a screen or component automatically inherits the following:
Variable values
Select Add State
Enter the name Hidden and click OK
Right-click on the HideShow folder
Select Add State
Select Shown
Verify the Font Scale is 1, or set it to 1 if not. This makes the Text regular size
Name the animation Show and click OK
Select the Show animation and click Add State
Select the Hidden state and click OK - this is the first keyframe in our animation
Click Add State again
Select Shown and click OK






Click to select the "AllInvisible" state.
Select one of the TextComponents
Set its HideShow State to Hidden
Repeat setting the State to Hidden for the other TextComponents
Select the ShowAll animation
Click "Add State"
Select "ScreenCategory/AllInvisible" and click OK
Select the Show animation and click OK
Select the newly-created animation and set its Time to 0.5
Repeat the above steps to add animations for the other two TextComponents, but set their times to 1.0 and 1.5































































true.Set the Sprite's Rotation (and optionally its Width and Height) to rotate and scale the clipped contents.
Sprite





















Y Units of Pixels From Baseline



Pixels from Baseline uses the bottom of the parent if it is not a Text instance







Image_Left.png
Image_Right.png
Image_TopCenter.png
Image_TopLeft.png
Image_TopRight.png




























Percentage Parent Width
X=50 places the origin halfway across the parent's width
Percentage of Parent
Fill (as %)
100 = same size as parent
Relative to Children
Hug
Container grows/shrinks to contain its children
Ratio of Parent
Flex grow
Siblings share available parent space proportionally
Percentage of Width/Height
Aspect ratio lock
Ties one dimension to the other
Auto Grid Horizontal
Grid, fills columns first
Auto Grid Vertical
Grid, fills rows first
Top-level Frame (a "screen" or "view")
Screen
Frame (layout container)
Container
Frame fill/stroke
Child ColoredRectangle or NineSlice inside the Container
Fixed size
Width/Height Units = Absolute
Fill container
Width/Height Units = Relative to Parent (value 0)
Hug contents
Width/Height Units = Relative to Children
Flex grow
Width/Height Units = Ratio of Parent
Padding
No direct equivalent — use child offsets or Relative to Parent with a negative value
Constraints (pin left/right)
X Units = Pixels From Left or Pixels From Right + X Origin
Constraints (pin center)
X Units = Pixels From Center, X Origin = Center
Constraints (scale)
X Units = Percentage Parent Width
Nine-point reference selector
X Origin + Y Origin
Auto Layout (vertical)
Children Layout = Top to Bottom Stack
Auto Layout (horizontal)
Children Layout = Left to Right Stack
Gap between items
Stack Spacing
Wrap
Wraps Children = true
Clip content
Clips Children = true
Component
Component
Component slot
Instance with Is Slot = true inside a component
Layer order
Tree position (earlier = behind, later = in front)
Min/Max width
Min Width / Max Width properties
Aspect ratio lock
Width Units = Percentage of Height (or vice versa)
X / Y
The numeric position value
X Units / Y Units
Which point on the parent to measure from
X Origin / Y Origin
Pixels From Left (default)
X=0 is the parent's left edge; positive X moves right
Pixels From Center
X=0 is the parent's horizontal center
Pixels From Right
Absolute
Fixed
Fixed pixel size, ignores parent
Relative to Parent
Fill (with offset)
Regular (default)
No Auto Layout
Top to Bottom Stack
Auto Layout, vertical
Left to Right Stack
Which point on the child is placed at that position
X=0 is the parent's right edge; positive X moves further right (past the edge)
0 = same size as parent; -20 = 20px smaller
Auto Layout, horizontal







X = 0, X Units = Pixels From Center, X Origin = CenterX = -10, X Units = Pixels From Right, X Origin = Right<VariableList xsi:type="VariableListSaveOfVector2">
<Type>Vector2</Type>
<Name>PolygonInstance.Points</Name>
<IsFile>false</IsFile>
<IsHiddenInPropertyGrid>false</IsHiddenInPropertyGrid>
<Value>
<Vector2>
<X>0</X>
<Y>46</Y>
</Vector2>
<Vector2>
<X>32</X>
<Y>32</Y>
</Vector2>
<Vector2>
<X>10</X>
<Y>0</Y>
</Vector2>
<Vector2>
<X>0</X>
<Y>46</Y>
</Vector2>
</Value>
</VariableList>Add a second state named Medium
Add a third state named Low
Be careful when editing objects with multiple states. You may end up making changes without realizing that you are doing so in the wrong state.
Whenever you have a non-Default state selected, Gum displays a label telling you which state you are editing.
Any unintentional change can be undone by pressing CTRL+Z






Container - invisible object used to contain other objects. These are used to provide margins, change layouts (such as vertical vs horizontal stacking), and to organize your UI.
NineSlice - visual object which uses nine sprites to create a resizable object from a source PNG (or portion of a PNG). The corner sprites (4) are not resized. The top, bottom, left, and right sprites are stretched on one axis. The middle sprite stretches both horizontally and vertically. These are used to create resizable frames.
Polygon - polygon outline which can have any number of points. These are usually not used for UI, but can be used if you are defining collision in your Gum objects for a game.
Rectangle - a rectangle which can be filled in, outlined, or both. Used for solid-colored backgrounds, frames, blocking out a UI, or for defining collision in your Gum objects for a game.
Sprite - a visual object which displays a source PNG (or a portion of a PNG). These are used for icons, backgrounds, and other visual objects which are usually not resized dynamically.
Text - a visual object which can display characters. These are used for any situation where text needs to be displayed such as labels and paragraphs.
Components are objects which can contain standard elements and instances of other components. Components can be very simple, such as a Label, or very complex, such as an options menu with dozens of instances. Items added to components or screens are called instances.
Screens are objects which can contain standard elements and instances of other components. Unlike Components, Screens cannot be added to other Screens. Screens exist mainly for organization. Screens can be simple, such as a loading screen, or complex such as a HUD in an RTS game.
Components and screens are similar - both can contain instances of standard elements, and both can contain other components. The only difference between screens and components is that screens cannot contain other screens.
For example you can think of screens in a video game which might include a main menu, credits screen, options screen, and level selection screen. You can think of components as elements which are composed of multiple standard elements. Examples include a Button component which is made up of a Sprite instance and a Text instance, or a Logo component which may be made up of multiple Sprites and Text objects.
Before you work on your project, you must first create a new project. You can save this project anywhere on your computer, but it's best to save the project in an empty folder so that all of the project files don't get mixed in with existing files.
To create a project:
Select File->New Project
Un-check the Include Forms controls option - this tutorial assumes a completely empty project
Select a new location somewhere on your machine for the new project. If you are using a library like MonoGame or raylib, you may want to save the project in a folder under your game project, such as a Content or Resources folder.
Once your project has been saved you should see its name in Gum's title bar.
To create a screen:
Right-click on the Screens tree item and select Add Screen
Enter the name of the new screen - such as MainMenu
Click OK. The newly-created screen is created and selected
Instances of standard and component elements can be added to screens and components. To add an instance:
Select the destination screen or component. For example, select the MainMenu screen
Drag the Text item onto the Editor tab
Release the mouse button. A new text instance appears in your screen.
Alternatively, you can also drag+drop a standard element into a screen in the tree view.
Once an instance is a part of a screen or component it can be edited visually in the preview window. The selected instance has eight (8) handles surrounding it. These are called the resize handles and can be used to change the selected instance's width and height.
In the case of the Text object, the resize handles are used to control how the text object performs line wrapping.
You can use the resize handles to resize the instance, or you can simply push the mouse button and drag inside the instance to change its position. Notice that an object's outline is displayed when the cursor is hovering over the instance.
This tutorial introduces the basics of working with standard elements and adding them to Screens. The next tutorial covers the Variables tab which can be used to access all element variables.



We can change the origin of the Text object by setting its X Origin and Y Origin values. Notice that if X Origin is set to Center then the Text object is positioned by its center:
You may need to pan the view in the Editor tab to be able to see the Text object. Gum provides multiple ways to pan the view:
Press and hold the middle mouse button while the cursor is over the preview window. While the middle mouse button is down, move the mouse cursor.
Use the scroll bars on the bottom and side of the view
Hold down CTRL and press the arrow keys
Changing the X Origin value changes the origin of the selected instance; however, it is still positioned relative to the top-left corner of the Text instance's container - which in this case is the entire screen designated by the dotted outline rectangle.
We can change the origin that the Text is relative to by changing the X Units. By default the X Units variable is set to Pixels From Left and Y Units is set to Pixels From Top.
Changing the X Units to Pixels From Right causes the Text to be positioned on the right-side of the screen.
The X,Y, Origin, and Units values are all available for every type of element in Gum; however, these values only change the bounds. In the case of a Text object we may be interested in how the text is aligned within the bounds. The Text object offers two variables for aligning its text: Horizontal Alignment and Vertical Alignment. Changing the Horizontal Alignment to Center centers the Text within its bounds:
You may have noticed that some variables in the Variables tab have an icon next to the variable label, while others are missing this icon.
Whenever an instance does not explicitly set a variable value, it uses a default value.
Gum lets us view and edit tese values.
To edit default values:
Right-click on the chip for a standard type, such as the Text chip
Select Edit Defaults...
Change the values that you would like to edit
Notice the default alignment values for Text
We can make changes to the default values now that the text is selected. For example, we can change the alignment values to be right and bottom. When we are editing any standard, the default values are displayed in the Editor tab so we can see these changes in real time.
Now if we select the TextIntance we will see that the Vertical Alignment is using the Bottom value; however the Horizontal Alignment is still using Center - this is because a value that is explicitly set on an instance will always override the default value set in the Standard element. Notice that Horizontal Alignment has an icon (indicating a custom value) and Vertical Alignment has no icon (indicating a default value).
Values can be reverted back to their default simply by right-clicking on the variable name in the Variables tab and selecting Make Default
You can undo the changes that you made to Standard Text by editing the defaults again and making the changes back to being top-left, or first editing defaults then pressing CTRL+Z to undo the changes.


Components can be made from-scratch or can be imported. Gum provides a full set of components for common controls including Button, TextBox, and ListBoxes, but for this tutorial we will be exploring how to build a component from scratch.
The first step in creating a component is to add an empty component and name it:
Right-click on the Components folder in Gum and select Add Component
Name the Component "HealthBar" (no spaces)
Next we'll add two Rectangle instances. One will be used as the background for the health bar, and one will be used as the fill for the health bar.
Drag+drop a Rectangle from the Standard folder into your Health Bar
Repeat this again to create a 2nd rectangle
If you dragged the instances on the tree view, the two Rectangle instances will overlap. We will adjust their positions later in this tutorial.
Next we'll rename the instances so their names match their purpose. Rename the first rectangle Background and the second Fill. You can press F2 or change an instance name in its Name text box in the Variables tab.
In this case, since Fill comes after Background, then it will draw on top. This ordering will become important when we make changes to these two instances later in the tutorial.
If you renamed them in the wrong order, you can also adjust their order in the component by selecting one of the instances, holding down the Alt key, and then pressing the up or down arrows to reorder the selected instance. You can also drag+drop to reorder, but be careful to not create an accidental parent/child relationship between the instances.
Next we'll adjust the Background Rectangle:
Select Background
Check the Is Filled variable
Set Fill Color to black - click on the colored box to open the color editor, or you can type the hex value 000000
Set Stroke Width to 0 - note that the stroke may not disappear since the Fill rectangle is still overlapping Background
Click on the Alignment tab and click the Fill button in the Dock row. This causes the Background to fill the size of its parent, and to adjust its own size if the parent HealthBar size changes.
Now the Background should be a solid black background to the entire component
Before moving on, you might want to spend some time adjusting values on your background. Although we removed the stroke and changed the background to black, you may want your HealthBar to have a different appearance. Try changing other values to get a feel for the different options provided by Rectangles.
Also, note that we clicked the Fill Dock button. This button is a shortcut which changes a number of variables on the component. Specifically this changed:
X, X Units, X Origin - the background will always be positioned horizontally according to its parent's center
Y, Y Units, Y Origin - the background will always be positioned vertically according to its parent's center
Width, Width Units - the background will always grow or shrink horizontally to fill its parent
Height, Height Units - the background will always grow or shrink vertically to fill its parent
For more information on docking, see the Dock page.
Next we'll adjust our Fill Rectangle, starting with its color:
Select Fill
Check the Is Filled variable
Set Fill Color to a green color - the exact value doesn't matter too much so pick a color you like
Set Stroke Width to 0
Unlike Background, the Fill rectangle needs to adjust in response to display how much health a player has. Specifically, the Fill rectangle needs to always fill its parent vertically, but its width depends on a health value.
First, we can adjust the height to fill its parent. To do this, set these values:
Set Height to 0
Set Height Units to Relative to Parent
Height Units and Width Units can be used to adjust the size of your object relative to its parent or children. In this case the parent is the entire health bar itself. Note that we've set up our Height and Height Units to be relative to parent manually, which is exactly what was done earlier when clicked the Fill Dock button. As mentioned earlier, the Fill Dock button is just a shortcut for setting these types of values.
Next we'll adjust our fill bar so that the width is a percentage of its parent rather than an absolute value.
Set Width to any value between 0 and 100. It should be 50 by default which is a good default
Set Width Units to Percent of Parent
Now if we adjust the Width value, the health bar width adjusts relative to its parent.
Now that we have set up both Background and Fill to be relative to their parent's size, we can adjust the size of the HealthBar component and all of the instances should also adjust automatically.
Select the HealthBar component and set the following values:
Set Width to 200
Set Height to 24
Now that we have a component created, we can add instances of this component the same way we have added standard elements. To do this:
Create a new Screen. I'll call mine GameScreen
Drag+drop the HealthBar component into the Screen
You can move and resize the newly-created HealthBarInstance in your screen. Notice that Background and Fill adjust in response to size changes on health bar.
You can also create copies by pressing CTRL+C, CTRL+V. Note that newly-created instances overlap the copied instance, so you need to move pasted instances.
Although we can can change the size and position of our health bars, we are missing some very important functionality - the ability to change how much health is displayed. The next tutorial discusses how to expose variables so that each instance can be modified.
Stacking objects on top of each other or side by side
Placing objects next to other objects which are dynamically sized
Creating tables and other complicated layout objects
For this example we'll create a Component for displaying distance. This component has two Text instances:
ValueText - the Text instance responsible for displaying the value for the distance. For example "100".
UnitsDisplay - the Text instance responsible for displaying the units for the distance. For example "km" for kilometers.
The two Text instances will have different colors so that ValueText stands out.
To create our component:
Create a new component named MeasurementDisplay
Drop two Text objects in the newly-created component
Name the first ValueText
Name the second UnitsDisplay
Next we'll make the UnitsDisplay use the ValueText as its parent:
Drag+drop UnitsDisplay onto ValueText to create a parent/child relationship
Change UnitsDisplay's X Units to Pixels From Right. This makes the text object positioned according to its parent's right edge
Change its X to 10 . This means the UnitsDisplay text is 10 units offset from the right edge of its parent ValueText
Verify its Y is 0
The ValueText actual width should be based on its contents, so we'll do the following:
Select ValueText
Change Width Units to Relative to Children
Change Width to 0
By setting these values, ValueText is now sized according to its children, which in this case are its letters.
You may have noticed that UnitsDisplay is also a child of the ValueText. However, since UnitsDisplay is explicitly positioned outside of the bounds of its parent ValueText, then ValueText ignores this child when calculating its own Width. For a detailed discussion of Width Units and whether children are ignored, see the Width Units page.
Now that we have adjusted the position, size, and parent values on our Text instances, let's modify the color of the UnitsDisplay:
Select the UnitsDisplay
Change Red to 200
Change Green to 150
Change Blue to 0
Now that we have set up a parent/child relationship between ValueText and UnitsDisplay, UnitsDisplay automatically adjusts its position in response to changes in ValueText. Any change on ValueText resulting in the right-side of the parent changing automatically adjusts the position of UnitsDisplay.
For example, if we change the Text property on ValueText, it grows or shrinks in response.
As mentioned above, changing the Text property causes ValueText to grow or shrink. However, regardless of its size, the Width property is still set to 0.
The Width variable is used in combination with its Width Units to calculate an effective width. In this case, the effective width is determined by the Text property on ValueText. It's important to note that all Gum objects have effective values for x, y, width, and height, all of which are determined by their respective units values.
Children always depend on their parents' effective values rather than their explicitly set values. Gum helps us visualize the effective values when we mouse over one of the resize handles on the selected object. For example, the following image shows the Width, Width Units, and effective width values of our ValueText.
Width is 0, Width Units is Relative To Children, effective width is 65Children outside of their parent's bounds still follow all of the same rules for sizing and positioning, but there are some important things to keep in mind.
Children placed outside of a parent do not affect the parent's effective width or height. Any unit value that depends on children or parents only considers the immediate child or parent and does not look at sizes beyond the immediate relationship.
For example if a parent has 100 effective width, and its child is given an X of 200, the parent's effective width remains 100 (assuming the parent does not size itself according to its children). This is important when other children are sized or positioned according to the parent's width.
The following animation shows three instances:
A parent container
A blue rectangle which is sized according to the parent rectangle
A yellow rectangle which is moved outside of the bounds of its parent
Notice that when the parent resizes the blue rectangle is also resized, but when the yellow rectangle is moved outside of the parent bounds, the parent and blue rectangle are not resized.
Children outside of bounds may not respond to click events unless the parent is explicitly checking for click events outside of its bounds. This is a property which is set at runtime. For more information see the RaiseChildrenEventsOutsideOfBounds page.
To change Parent in the Project tab:
Select a child
Drag+drop the child onto the desired parent
The child can be detached from its Parent by drag+dropping it onto the Component.
Drag+dropping onto a parent may set the Parent property to an instance inside of the parent's Component type sets its Default Child Container value. For more information see the Default Child Container page.
To set Parent by name:
Select the desired child
Change the Parent property to the desired parent:


Exposed variables
Instances
Available variables, such as stacking if inheriting from a container
Inheritance is useful if your project needs multiple screens or components which share common variables or instances.
All instances must have a Base Type set. For example, the following instance is of type Container.
Base Type is automatically assigned when a new instance is created. For example, the following animation shows a new ColoredRectangle instance created. Note that its Base Type is automatically assigned to ColoredRectangle.
Base Type can be changed after an instance is created. Keep in mind that doing so does not change its name or any other properties, so you may need to manually adjust properties when converting between different Base Types. Also, note that default values may change when switching from one Base Type to another.
The following shows a ColoredRectangle changed to a Container. Since Container and ColoredRectangle have different default Width and Height values, changing Base Type results in changes to default size too.
Base Type can change other variables such as Width and HeightAll components use inheritance even if their Base Type variable is not set explicitly. By default components inherit from the Container type.
By inheriting from the Container type, components have access to all Container variables such as Children Layout.
Components can inherit from standard types. For example, instead of inheriting from Container a component may inherit from ColoredRectangle. By doing so, it has access to all properties on the ColoredRectangle type.
Components can inherit from other components. By doing so the component inherits all children and exposed variables from its base component.
A component which inherits from another component is often called a derived component. The component which is being inherited from is often called a base component.
A base component can be used to define instances which the derived component can modify. For example a component named ButtonBase may define that all components have a ColoredRectangle named Background and a Text named TextInstance.
If another component uses ButtonBase as its Base Type, then this component automatically gets Background and TextInstance children which match the base instances.
The CancelButton can modify variables on the added children. For example the CancelButton can modify the Text on the TextInstance and the color values on the Background.
The derived component has the following restrictions when working with children instances:
Name cannot be changed. For example Background must always be named Background.
Base Type cannot be changed. For example, the base type for Background must be ColoredRectangle
Children defined in the base cannot be removed. For example, the Background child cannot be deleted from CancelButton. Children can be made invisible.
If the base type adds new instances, then the derived types automatically get the same instances added as well. Similarly, if the base type deletes a child, then the child is also removed from the derived type.
Derived types get access to all of the exposed variables in the base type. For example, if ButtonBase exposes the TextInstance's Text property, this is also available on the derived component.
Base Types allow for the customization of a component, including the creation of many variants. Similarly, States also allow for the customization of a component in similar ways. When deciding between whether to use states or inheritance, keep the following in mind:
States are often used to set variables temporarily, while inheritance is permanent. For example, a button may set its background color values in response to being highlighted. By contrast, a Cancel button may always say "Cancel".
States do not allow for the creation of new instances. Although derived components cannot delete children which are defined by their Base Type, derived components can add additional instances.
Components can use multiple categories. Therefore, it may not be clear which category defines the type of component. A component can only have one Base Type, so its type is defined clearly.
Introduction
Health bars are common UI elements in games. They are similar to progress bars, so this example could be used to create either. This example explains how to create a health bar component.
First we'll define the component:
Open Gum
Open or create a new Gum project
Right-click on the Components folder
Name the component "HealthBar"
Resize the HealthBar component so it is wider than it is tall. For example, assign Width to 200 and Height to 32.
Next we'll add a background to our HealthBar Component
Drag+drop a ColoredRectangle into the HealthBar\
Select the newly-created ColoredRectangleInstance
Select the Alignment tab
Now we have a black background in our HealthBar
The HealthBar displays its current health with another rectangle. This second rectangle will be contained inside a container to provide a boundary. To add an inner container:
Drag+drop a Container onto the HealthBar
Select the Alignment tab
Enter a Margin value of 4
Click the
Now we have a ContainerInstance with the proper margin
Finally we'll add the foreground rectangle which displays the health:
Drag+drop another ColoredRectangle onto the ContainerInstance. Be sure to drop it on ContainerInstance so that the newly-added ColoredRectangle is a child of the container
Click the Alignment tab
Set Margin back to 0
Click the Fill Dock button
Now, the Width value can change between 0 and 100 to indicate the health percentage.
Next we'll expose the inner ColoredRectangle's Width property so it can be assigned per HealthBar instance:
Select the inner ColoredRectangle instance
Right-click on its Width variable and select Expose Variable\
Enter an appropriate name such as "Percentage" and click OK
Now we can add instances of the HealthBar to a screen and control its fill percentage.
\
States are a powerful way to create expressive groups of variables. Some UI elements may require a combination of states to be applied simultaneously.
For example, consider a Button component which displays a button callout.
This button might be a standard Button with the following states:
Enabled
Disabled
Although Gum includes a standard NineSlice element, the Gum layout system can be used to create a custom NineSlice component. Such a component could be used if additional flexibility beyond what is provided by the standard NineSlice is needed.
As implied by the name, the NineSlice element is composed of nine Sprites. First we'll create the component:
Open Gum
Open or create a new Gum project























































Click the Fill Dock button\
Change the ColoredRectangleInstance color to black\
Change the following values:
X Units to Pixels from Left
X Origin to Left
Width to Percentage of Container
Width to 100






Highlighted
Pushed
But it may also have states for which button icon to display:
A
B
X
Y
LeftStick
RightStick
These two sets of states could be set independently and combined at runtime. Categories let you create groups of states so that multiple states can be set simultaneously.
For this tutorial we'll create a new component. This component has state categories for size and for color. To do this:
Open Gum
Create a new Component called CategoryDemo
Right-click anywhere in the State box and select Add Category
Enter the name "Size" for the new category and click OK
Repeat the above steps to create a "Color" category
Now we can add states to the categories. To do this:
Right-click on the Size category and select Add State
Enter the name "Small" for the new state
Right-click on the Size category again and select Add State
Add a second state to "Big"
Right-click on the Color category and select Add State
Add a state called "Red"
Right-click on the Color category again and select Add State
Add a state called "Blue"
Now that we have states set up we need to add a visual element to the component so that we can see our changes.
To do this, select the Default state and drag+drop a Rectangle into your component. Check its Is Filled variable, and set its Stroke Width to 0.
To modify a state, you can select it and edit in the Editor tab or change properties in the Variables tab to modify what the state sets. Notice that normally for a component like this the RectangleInstance would have its width and height be relative to its container, but we're not doing this for the sake of keeping the tutorial shorter.
First we'll set the Size states. To do this:
Select the Big state
Resize the colored rectangle so it is larger than the default
Select the Small state
Resize the colored rectangle so it is smaller than the default
Next we'll set the Color states. To do this:
Select the Red state
Set Fill Color to a red color
Select the Blue state
Set Fill Color to a blue color
Your states now should reflect the colors set.
Now that we have our CategoryDemo component set up with multiple categories, we can view these states on any CategoryDemo instance. To do this:
Create a Screen called CategoryDemoScreen
Drop an instance of the CategoryDemo component into the CategoryDemoScreen
Select the newly-created CategoryDemoInstance
Scroll down in the Variables list and notice that the instance has drop-downs for each category.
You can set each state independently and the states combine
We can revert the states back to their unset values by right-clicking on the state variable and selecting the Make Default item.
If a variable is modified in one of the states in a category, then all of the states in that category are automatically assigned the default value, and this value is explicitly set. This concept makes working with states far more predictable.
For example, consider a component which has:
A single Rectangle
A category called RectangleSizeCategory
States called Big, Medium, and Small
Initially, all states in a category do not explicitly assign any variables. We can see this by selecting the category and observing the Variables tab.
If a variable is changed in one of the states in the category, then that variable propagates to all other states, and the Category lists this as one of the variables that it modifies.
For example, we can select the Big category and change the Rectangle.Width property to 150.
Once this value is changed, the RectangleSizeCategory lists this as a variable that it modifies in the Variables tab.
If we select any of the other states in the category, they show that they explicitly set the Width value as well (the value has a white background instead of light green). The value is inherited from the default state.
Once a variable is set in a category, all states are required to set this value. A variable cannot be removed from a single state in a category. Rather, to remove a variable, all states in the category must remove the variable. This can be done by selecting the category and pressing the X button next to the variable name.

Select Add Component
Name the Component "CustomNineSlice"
Next, we'll add corner Sprite instances to our CustomNineSlice. We'll be using the alignment tab to position Sprites. The alignment tab provides a quick way to place objects, but the same could be achieved using the following variables individually:
To create the corner Sprites:
Drag+drop a Sprite element onto the CustomNineSlice component
Click the Alignment tab
Anchor the newly-created Sprite to the top-left of its container
Repeat the steps above three more times, creating one Sprite for each of the four corners, anchoring each one to their respective corner
Notice if we resize our CustomNineSlice component, each of the four Sprites remains in its respective corner.
Next we'll add the four Sprites which will sit on the edges of our component:
Drag+drop a Sprite element onto the CustomNineSlice component
Click on the Alignment tab
Dock the newly-created Sprite to the top of its container. Docking sets the width of the sprite to match the width of the component. We'll address this in the next step.\
To accommodate for the corner Sprites, we need to adjust the width of the top Sprite. Set the newly-created Sprite's Width to -128. Since the Sprite uses a Width Units of Relative to Parent, setting the value to -128 makes the Sprite 128 units smaller than its parent. We picked 128 because each of the corner sprites is 64.\
Repeat the above steps, but instead setting the dock to create sprites on the left, right, and bottom. adjust width and height values as necessary.
Finall we'll add the center Sprite:
Drag+drop a Sprite element onto the CustomNineSlice component
Click on the alignment tab
Dock the newly-created Sprite to the center of its container.
Set both the newly created Sprite's Width and Height to -128
Now the Sprites stretch and adjust whenever the CustomNineSlice is resized.
Unlike the regular NineSlice, changing the texture values requires a considerable amount of variable assignment. To change the CustomNineSlice to use 9 separate textures, the following values must be set:
Each of the Sprite instances must have its SourceFile value set
The edge Sprites will have to have their Width and Height values modified to account for the possible resizing of the corner sprites
The center Sprite will have to have both its Width and Height values modified
If using a sprite sheet, then all of the work above will need to be done plus the texture coordinate values will need to be modified.
The Blend variable controls how the selected instance combines its colors with whatever is drawn before. The final appearance depends on its Blend, Alpha, Source File, and Color values.
Blend is available on the following types:
(if is set to true)
Blend is also available on all Skia elements:
Most examples on this page overlay a Sprite over ColoredRectangles, but the same Blend behavior applies to all items which support the Blend variable.
Normal Blend is the default value. When an instance uses Normal Blend, it interpolates its color with whatever it draws on top of using its Alpha value as a weight.
If a Normal Blend Sprite has an Alpha of 255, then the Sprite completely replaces whatever is below.
If a Sprite has an Alpha of 128 (roughly half of 255), then it averages its color with whatever is below.
A Sprite with an Alpha of 25 (roughly 10%) blends with whatever is below, but its color is given a weight of roughly 10%.
Additive Blend results in the color of a element being added to whatever is below. This typically results in brighter colors. Additive Blend can be used to simulate a light.
Since Additive Blend results in a modification of what is under instead of a replacement, an Additive Blend Sprite typically appear transparent even when Alpha is 255.
As Alpha is reduced, the brightening effect is reduced. A Sprite with an Alpha of 128 only applies roughly half as much of a brightening effect.
A Sprite with an Alpha of 25 applies a slight brightening effect.
Stacking multiple Sprites with Additive Blend results in the brightening effect stacking as well.
Replace Blend results in the instance completely replacing whatever it is drawn on top of regardless of its Alpha or transparency in the source file.
A Sprite with no transparency in its source file drawn with Alpha of 255 looks the same whether it uses Replace or Normal Blend.
Changing the Alpha on a Sprite with Replace Blend does not affect how it is drawn - it is always drawn at full opacity.
Replace Blend results in a Sprite being fully opaque even if its source file has transparency. The following image shows two Sprites displaying the same image.
Gum supports Blend modes which modify the alpha (opacity) of whatever is under the instance using the alpha-only Blend . Alpha-only Blend modes ignore the color of the instance using the Blend - only the alpha matters (see note below about premultiplied alpha). Therefore, the following three circles would behave the same despite having different colors:
Since alpha-only blends operate directly on the alpha of whatever is below, they are only intended to be used on Containers with Is Render Target set to true. Usually objects with these blend modes are drawn on top of all other items in the container. For example, the following image shows a RenderTargetContainer which holds a number of items including the AlphaOnlyCircle. AlphaOnlyCircle is an instance which can be used to apply Alpha-only Blends to whatever is below.
Using an alpha-only Blend outside of a container with Is Render Target set to true typically results in the instance either being drawn as pure black or being invisible.
Subtract Alpha Blend subtracts, or "cuts out", the alpha of whatever is below.
As Alpha is reduced, the amount of opacity removed effect is also reduced. A Sprite with an Alpha of 128 only removes roughly half as much opacity from what is below.
Replace Alpha forcefully sets the opacity of whatever is below. Rather than subtracting alpha, replace can forcefully set the alpha.
Replace Alpha with an Alpha value of 255 results in no changes if what is under is already opaque, but it can add alpha if what is under is transparent.
If Alpha is reduced, then the resulting pixels display the explicitly set alpha. The following shows setting alpha explicitly to 128 (about 50%).
Setting Alpha to 0 forcefully sets whatever is under to fully transparent. This is similar to performing Subtract Alpha with an Alpha of 255.
Keep in mind that Replace Alpha can apply different alpha values if the instance itself has variable alpha, such as a Sprite with some parts transparent and some parts opaque.
Min Alpha modifies the underlying object so that the result is the minimum alpha between the instance and what is below. This can be used to create an alpha mask.
If the instance alpha is reduced, then the resulting transparency is reduced as well. The following shows setting Alpha to 128 (about 50%).
Keep in mind that multiple objects can be combined to create larger masks. For example, additional ColoredRectangles can be added to the circle above to create a larger mask. Each rectangle also has its Blend set to Min Alpha.
By default, a new Gum project has no behaviors. The most common way behaviors enter a project is automatically: adding Forms controls (Button, TextBox, Slider, and so on) adds their matching behaviors for you - see below.
Creating or editing behaviors yourself is an advanced, rarely-needed scenario. The vast majority of projects only ever use the behaviors that Forms controls bring in automatically.
A behavior defines requirements that are reusable across multiple components: required categories and states, required instances, and optionally Behavior Properties - design-time properties that surface in a Behavior category in the Variables tab and connect to properties on the runtime Forms control (such as TextBox's TextWrapping or Slider's Minimum/Maximum). Behavior Properties are covered in below. If a component uses a behavior, then the component is forced to include categories and instances according to the behavior definition.
The Dock section of the Alignment tab is used to easily adjust the variables on an instance for common layouts. All Dock options adjust the dimensions of the current instance, and most also adjust the position.
Keep in mind that docking an instance does not toggle a dock state, but rather modifies variables on the instance so that it has docking behavior. This distinction has the following consequences:
Docking behavior can be achieved by manually modifying variables - this tab does not add any additional behavior which is not already available through the Variables tab.
Docking cannot be undone by toggling the dock button, and pressing multiple dock buttons results in multiple dock variables being assigned which may result in undesirable behavior. To undo docking, use the CTRL+Z shortcut for undo.
This document walks through creating a behavior from scratch, using a ButtonBehavior-style definition as a familiar illustration. You would not actually recreate ButtonBehavior in a real project — it already exists - but the same steps apply to any custom behavior you define for your own components.
To add a behavior:
Right-click on the Behaviors folder
Select Add Behavior:
Runtimes which use premultiplied alpha (such as FlatRedBall) require using objects that are fully white when modifying alpha. Otherwise, the color of the overlaying instance will blend with the underlying object.






































Common behavior usage falls into one of two categories:
Behaviors for built-in controls such as Button and TextBox exist to make customization for these types of controls easier.
New behaviors can be created to match the syntax of controls defined in your game project. This is considered an advanced scenario and is rarely used.
If your project has added forms components, then it should contain a set of default behaviors matching the forms control types.
These behaviors are used by the Gum runtime to decide whether a component should have the behavior of a particular control type.
For example, a component with a NineSlice background will not respond to cursor hover events by default. However, if the ButtonBehavior is added to this component, then the component is required to contain certain states which are used at runtime to react to hover, push, and disable states.
In other words, behaviors answer the question "How can I give default forms behavior to my component" by providing a required set of states, instances.
As mentioned above, if you have added forms controls to your project, then you should have a set of components which already implement the default behaviors defined below.
For example, we can look at the ButtonStandard component which implements ButtonBehavior.
By using the ButtonBehavior, the ButtonStandard will automatically be associated with the Button type at runtime.
Furthermore, the ButtonStandard component is required to include the category and states defined by ButtonBehavior.
Notice the categories and states defined by ButtonBehavior:
These automatically-added states are empty - they do nothing by default. For information on working with states, see the States page.
Gum prevents the removal or renaming of any of these states from ButtonStandard since they are required by ButtonBehavior.
If you are creating a new component which should be used as a standard forms type, such as creating a new Button style, then you will need to add a behavior to the component. By adding a new behavior, Gum will add required states automatically and will display errors if any behavior requirements are missing.
For example, consider the creation of a new component which will have button behavior (responding visually to hover and push, enabled/disabled support, and click events).
To add the ButtonBehavior to a component:
Select your component
Click the Behaviors tab
Click the Edit button
Check the desired behavior ( ButtonBehavior )
Click OK to apply the selected behavior
Gum automatically creates the ButtonCategory and required states. Keep in mind that these states are empty - it is up to you to select the states and customize your component appropriately.
Some behaviors have instance requirements too. For example, the TextBoxBehavior has two required instances:
TextInstance which uses a base type of Text
CaretInstance which can be of any type
TextBoxBehavior has required instancesIf this behavior is used in a component, Gum displays errors indicating that instances are missing.
You need to add instances to your component to satisfy these errors or else the component may not function properly at runtime, and may even cause runtime crashes.
Beyond categories, states, and instances, a behavior can declare Behavior Properties — design-time properties that appear in a Behavior category in the Variables tab and flow through to the matching property on the runtime Forms control. For example, TextBoxBehavior declares properties matching TextBox's TextWrapping, AcceptsReturn, IsReadOnly, and MaxLength; SliderBehavior declares properties matching Slider's Minimum and Maximum. Setting one of these in the Variables tab sets the corresponding property on the control when your game runs.
Some Behavior Properties also drive a visual state automatically, so you get a design-time preview even though Forms controls don't run inside the tool. For example, setting TextWrapping in the Behavior category updates the component's visual line-mode state immediately. See Behavior-Driven References for how this works.
You can add your own Behavior Properties and behavior-driven references to a custom behavior you create, but this is an advanced, rarely-needed scenario. See Behavior Properties on Custom Behaviors for a brief overview.
X
0
X Units
Pixels From Center
Y
X
0
X Units
Pixels From Left
Y
0
Y Units
X
0
X Units
Pixels From Center
Y
0
Y Units
Y
0
Y Units
Pixels From Center
Y Origin
Center
Height
X
0
X Units
Pixels From Right
Y
0
Y Units
X
0
X Units
Pixels From Center
X Origin
Center
Width
X
0
X Units
Pixels From Center
Y
0
Y Units
Width
0
Width Units
Relative to Children
Height
0
Height Units

Enter the new behavior name. Often time the word Behavior is added at the end of the name, such as ButtonBehavior
New behaviors appear in the Project tab.
Once a behavior is created, it can be given categories, states, and instances. Components which use this behavior are required to have matching categories and states.
The process of adding and removing states to behaviors is the same as adding and removing states in other elements. For more information, see the States page.
For example, the ButtonBehavior may have the following:
ButtonCategory (Category)
Enabled (State)
Disabled (State)
Focused (State)
Pushed (State)
A behavior can have as many categories and states as needed.
Once a behavior is added, it can be used in a component. To add a behavior to a component, drag+drop the behavior onto the component in the tree view.
Behaviors can also be added and removed on the component's Behaviors tab:
Select a component which should use the behavior
Click the Behaviors tab
Click the Edit button
Check the desired behaviors - a component may use multiple behaviors
Click OK
Notice that once a behavior is added to a component, the component automatically creates the matching categories and states.
If the behavior is selected in the Behaviors tab, the required states and categories are highlighted in the States tab.
These categories cannot be removed as long as the component uses the behavior.
As mentioned above, if a component uses a behavior, then the component is required to include all of the states and categories defined by the behavior. If a behavior is added to a component, then all states and categories in the behavior are automatically added to the component. Keep in mind that newly-added states do not automatically assign any values. The behavior only requires that the states exist but it does not decide which variables are assigned by the states. These required states can even be left to their default so they have no affect on the component.
Required states and categories cannot be removed or renamed. Required states cannot be moved to different categories.
If a new category or state is added to a behavior, all components which use the behavior also have the new category or state added.
If a state or category is removed from a behavior, Gum does not remove the state or category from components which implement the behavior. Behaviors only define what is required, but they do not prevent components from defining additional states and categories. Also, the states on components may still be needed even if the behavior is removed. Therefore, if you remove any states or categories from a behavior, you may need to manually remove the same states and categories from components which use the behavior if these are no longer needed.
Behaviors can include instances, resulting in required instances existing in components which use the behavior. Instances in behaviors only include two properties:
Name
Base Type
Instances in behaviors only require that instances in components have these two matching properties. All other properties can be set to any value.
To add an instance to a behavior, drag+drop a standard element or component onto the behavior in the Project tab.
An instance can have its Name changed, Base Type changed, or removed.
If a component is missing a behavior then the Error window provides information about the missing requirement.
The standard Forms behaviors ship with Behavior Properties (see Behavior Properties) that surface a Behavior category in the Variables tab and drive design-time preview. A custom behavior can declare these too, but there is currently no tool UI for it - they are added by hand-editing the behavior's .behx file. This is an advanced, rarely-needed scenario; the standard Forms behaviors already cover the common cases.
Standard Forms behaviors (ButtonBehavior, TextBoxBehavior, and so on) already ship with every project that uses Forms controls - see Behaviors. Creating or editing a behavior yourself is a rare, advanced scenario, needed only when you're standardizing categories/states/instances for your own components that are not part of Gum Forms.
The Anchor section of the Alignment tab is used to adjust the variables on an instance for common layouts. All Anchor options adjust position-related variables, but do not adjust dimensions.
Using the Anchor buttons does not toggle an anchor state, but rather modifies variables on the selected instances so that it is anchored to the correct side or center. This distinction has the following consequences:
Anchoring behavior can be achieved by manually modifying variables - this tab does not add any additional behavior which is not already available through the Variables tab.
Anchoring cannot be undone by toggling the anchor button. Pressing the anchor button multiple times results in the same variables being assigned multiple times. To undo anchoring, use the CTRL+Z shortcut for undo.
Children Layout determines how a container positions its children. The default value is Regular which means that children are positioned according to their and .
Top to Bottom Stack results in the children stacking one on top of another, from top to bottom.
Left to Right Stack results in the children stacking one beside another, from left to right.
Auto Grid Horizontal results in the children being placed in a grid, filling in horizontally first before wrapping to the next row.







0
Y Units
Pixels From Top
X Origin
Center
Y Origin
Top
Width
0
Width Units
Relative to Parent
Pixels From Center
X Origin
Left
Y Origin
Center
Height
0
Height Units
Relative to Parent
Pixels From Center
X Origin
Center
Y Origin
Center
Width
0
Width Units
Relative to Parent
Height
0
Height Units
Relative to Parent
0
Height Units
Relative to Parent
Pixels From Center
X Origin
Right
Y Origin
Center
Height
0
Height Units
Relative to Parent
0
Width Units
Relative to Parent
Pixels From Bottom
X Origin
Center
Y Origin
Bottom
Width
0
Width Units
Relative to Parent
Relative to Children








X
0
X Units
Pixels From Left
Y
0
X
0
X Units
Pixels From Center
Y
X
0
X Units
Pixels From Right
Y
X
0
X Units
Pixels From Right
Y
X
0
X Units
Pixels From Center
Y
X
0
X Units
Pixels From Center
Y
X
0
X Units
Pixels From Left
Y
X
0
X Units
Pixels From Center
Y
X
0
X Units
Pixels From Right
Y
X
0
X Units
Pixels From Center
X Origin
Y
0
Y Units
Pixels From Center
Y Origin

Auto Grid Vertical results in the children being placed in a grid, filling in vertically first before wrapping to a new column.The following animation shows how to use the ChildrenLayout variable to change the default position of a Container's children:
Regular layout positions each child independent of every other child. The position of one child does not affect the position other children. This is the default layout for containers.
Top to Bottom Stack results in each child being positioned after its previous sibling vertically. This can be used to create horizontal stacks.
Top to Bottom Stack behaves similarly to Left to Right Stack. For a detailed discussion see the Left to Right Stack section below.
Left to Right Stack results in each child being positioned after its previous sibling horizontally. This can be used to create vertical stacks.
A container can stack its children and also have its size based on its children. This results in the container growing as children are added.
For example, the following shows a container with its Height Units set to Relative To Children and its Children Layout set to Top To Bottom Stack. As more children are added the container grows vertically.
Invisible children are ignored in the stack, so toggling the Visible property removes a child from the stack.
When children stack, each child's X or Y depends on the boundary of its previous sibling. When stacking vertically, the child's Y value begins at the bottom side of the previous item. Similarly, when stacking horizontally, the child's X value begins at the right side of the previous item.
For example, the following image shows a Text object with a Y value of 20. Notice that it is positioned 20 units below the item above it.
This effect is easy to notice when dragging an object inside a stack, as shown in the following animation:
If instances are stacked in a container, the stacking controls the instance values based on the direction of the stack.
Top to Bottom Stack containers control the Y value of their children.
Left to Right Stack containers control the X value of their children.
The position value which is not controlled by the stack can be changed freely without any impact on the stacking.
For example, if a container stacks its children using a Top to Bottom Stack, the children in the stack are free to change their X values. The following animation shows how children can be left, center, or right anchored (which changes their X Units and X Origin) without affecting the other children in the stack.
Top to Bottom Stack and Left to Right Stack separate their children using the Stack Spacing value. For more information, see the page.
The position of a child in a stack is determined by the size of the previous item in the stack and the origin of the child. In most cases children which are stacked should use a Left if the parent uses a Left To Right Stack and should use a Top if the parent uses a Top To Bottom Stack.
Consider a container with a blue rectangle which stacks horizontally. The blue occupies some space according to its absolute width. The next instance after the blue rectangle is placed relative to the right-side of the blue rectangle.
For example, if a red rectangle (partially transparent to make it easier to see when overlapping) is added to the container, the stack may create a layout similar to the following image:
Keep in mind that the stack simply states the position of the next item. Each item can freely adjust its X Origin (or Y Origin in a Top to Bottom Stack). If the red rectangle's is changed to Center, the red rectangle overlaps the blue rectangle.
If the red rectangle's is changed to Right, then its right side aligns with the right side of the blue rectangle, resulting in the red overlapping the blue completely. In this case the red rectangle's stacking is essentially cancelled out by the .
This overlapping may not be desirable, so keep this in mind when changing a stacked child's origin.
The property controls how stacking behaves beyond boundaries. For more information, see the page.
Children of a container which uses the Top To Bottom Stack or Left To Right Stack are ordered according to their order in the tree view on the left. By default this is the order in which the children are added to a parent container.
Children can be reordered using the right-click menu on an instance.
Alternatively, children order can be changed by clicking on the item in the tree view, holding down the ALT key, then pressing the up or down arrows.
For more information on ordering, see the page.
Auto Grid Horizontal and Auto Grid Vertical layouts result in each child of the container being placed in its own cell. All position and size values are relative to the entire cell, so children can expand to fill their cell or be positioned according to any side or corner.
The following image shows a container with 4x4 auto grid. Each child is positioned relative to the top-left corner of each grid. In this case, each child has an Absolute Width and Height of 50 and the parent container is sized 256x256. This results in each rectangle leaving a gap between itself and its neighbor.
The following shows a container with an Auto Grid Horizontal and Vertical Cells of 2, resulting in a 2x2 grid. As children are added to the container through copy/paste, each child is placed in its own cell.
The number of cells is controlled by the Auto Grid Horizontal Cells and Auto Grid Vertical Cells. Increasing the number of cells results in the rows or columns adjusting automatically.
Each child occupies one cell, and the order of the children controls the order of the placement in grids. The first child occupies the top-left row. If using Auto Grid Horizontal, each child is placed to the right of its preceding sibling, wrapping to the next line when reaching the end of a row. If using Auto Grid Vertical, each child is placed below its preceding sibling, wrapping to the next column when reaching the end of a column.
Children can be reordered by using the alt+arrow key in the tree view, resulting in reordering just like when using a stacking Children Layout.
Children treat their particular cell in the grid as their parent, so any sizes or positions will be based on their parent cell. In other words, if a child's Width Units is set to Relative To Parent, the parent in this case is the cell, not the entire Container instance.
The number of cells in a grid is determined by multiplying Auto Grid Cells Horizontal by Auto Grid Cells Vertical. If a container has more children than its total cells and if the container's size does not depend on its children, additional children spill over the bounds of the grid. The following animation shows a 3x3 grid using Auto Grid Horizontal. As more children are added, additional rows are added below the bounds of the grid.
If the container has its Width Units or Height Units set to Relative To Children, then its size may adjust in response to adding more children. For more information, see the and pages.
When using Auto Grid Horizontal, the number of columns is fixed, but additional rows can be added beyond the bounds of the container.
When using Auto Grid Vertical, the number of rows is fixed, but additional columns can be added beyond the bounds of the container.
Stack Spacing can be used to separate cells in a grid. This is most commonly used when the grid's children use Width Units or Height Units of Relative to Parent.
The following shows a grid with children which fill their cells. Changing the Stack Spacing adds gaps between each child.
If a container's Children Layout is set to Auto Grid Horizontal or Auto Grid Vertical, it can size itself according to the largest cell by using Width Units or Height Units of Relative To Children. For more information see the and pages.











Y Units
Pixels From Top
X Origin
Left
Y Origin
Top
0
Y Units
Pixels From Top
X Origin
Center
Y Origin
Top
0
Y Units
Pixels From Top
X Origin
Right
Y Origin
Top
0
Y Units
Pixels From Center
X Origin
Right
Y Origin
Center
0
Y Units
Pixels From Center
X Origin
Center
Y Origin
Center
0
Y Units
Pixels From Center
X Origin
Center
Y Origin
Center
0
Y Units
Pixels From Bottom
X Origin
Left
Y Origin
Bottom
0
Y Units
Pixels From Bottom
X Origin
Center
Y Origin
Bottom
0
Y Units
Pixels From Bottom
X Origin
Right
Y Origin
Bottom
Center
Center





































Height Units controls how a unit is vertically sized, which may be relative to its parent. By default most types uses Absolute height, where each unit represents 1 pixel of height in pixels. When using Absolute, an object ignores its parent's Height.
The following shows a child ColoredRectangle with 50 Absolute Height:
Text instances which use an Absolute height of 0 size themselves to be the height of their contained text. This behavior will likely change in future versions of Gum so this combination is not recommended. Instead, to size a Text instance according to its contained text, Set Height Units to Relative to Children.
The following shows a child ColoredRectangle with -10 Relative to Parent Height, which means is sized 10 pixels less tall than its parent.
The following shows a child ColoredRectangle with 100 Percentage of Parent, which means it has 100% of the height of its parent. Note that 100 Percentage is the same as 0 Relative to Parent:
Ratio of Parent can be used to fill available space or to share available space with other objects using a ratio.
The simplest case is a single child in a container with its Height Units set to Ratio of Parent.
In this case the blue has no siblings (its parent has no other children), so it occupies the entire parent height. If a second child is added (by copy/pasting the existing child), then each child is given 1 ratio value, which means each is 1/2 of the size of the entire parent.
To better visualize the effect of ratio, it's common to set the parent's to Top to Bottom Stack, and to give each child a different color as shown in the following image.
As more children are added, each child's height is adjusted to make room for the new children.
Ratio values are distributed among all siblings using Ratio of Parent proportionally. The image above shows four siblings, each given 1/4 of the ratio. If one of the the ratios changes (such as by increasing the second sibling's Height value to 3), then all siblings adjust in response to this change.
In this case, the total ratio is 6 (1 + 3 + 1 + 1), so the red is given 3/6 (1/2) of the parent's height, while each of the others is given 1/6 of the parent's height.
Values of 0 are supported, resulting in the object drawing with an absolute height of 0.
Ratio of Parent is calculated after accounting for the height of children which are using absolute height. For example, if the height of the first child is 80 with a Height Units of Absolute, then the other three shrink to give the first the necessary room.
This effect can also be seen by adjusting the height using the handles.
Gum ignores invisible objects when calculating available space for Ratio of Parent units. Therefore, if a sibling is invisible, Gum treats it as if it has 0 height which allows all other ratio siblings to expand.
Ratio of Parent also respects . A Stack Spacing value greater than 0 removes the available space for all children with a Height Units of Relative to Parent.
The following image shows a child with 50 Relative to Children Height, which means that it is 50 pixels taller than is necessary to contain its children. Since the rectangle has no children, this is the same as having 50 Absolute Height:
Relative to Children can be used to size an object based on the position and sizes of a parent's children. The following image shows a container with 0 Relative to Children Height, which means that its height is set just large enough to contain its children. Notice that if the children are moved, the parent's height adjusts. Both children are considered so the container adjusts its height according to the bottom-most side of either child:
A non-zero Height when using Relative to Children can be used to add additional padding to a parent container. The following animation shows how changing the height can adjust the absolute height relative to children:
A parent container can ignore its children when it determines its own height when using a Height Units of Relative to Children if any of the following are true:
The child's Ignored By Parent Size is true.
The child's height depends on its parent's height. This circular dependency is resolved by the parent ignoring this child.
The child is explicitly positioned outside of parent's bounds
The child's Y Units
If a child has its Ignored By Parent Size set to true, then the parent ignores this child when calculating its own size. For more information, see the page.
If a child's height depends on the parent, then the child is ignored by the parent. Once the parent has determined its own height, then the child is sized according to the parent. This type of circular dependency is common when adding background visuals to a container.
For example consider a container with two children - BlueRectangle and YellowRectangle - with the following variables:
BlueRectangle Y = Pixels from Top
BlueRectangle Height Units = Absolute
YellowRectangle Height Units
Only YellowRectangle depends on its parent.
Since BlueRectangle's absolute height value does not depend on the parent, the parent can use BlueRectangle's absolute height when calculating its own absolute height. Since YellowRectangle depends on the parent, the parent ignores the YellowRectangle. Instead, YellowRectangle depends on the parent container's absolute height for calculating its own absolute height. This in effect creates a situation where BlueRectangle affects the height of both its parent and also its YellowRectangle sibling.
A parent does not consider a child if the child is explicitly positioned outside of the parent's bounds. This can happen if the child's Y Units and Y values result in the child being drawn outside of the parent's bounds.
If a child has Y Units of Pixels from Top and its Y value pushes the child out of the top of its parent, then the portion that is outside of the top of the parent is ignored. The BlueRectangle in the following image has an absolute height of 50. Its Y value is -20, so only 30 pixels are used to determine the parent's height.
Similarly, if a child uses a Y Units of Pixels from Bottom then the parent does not consider the height of any portion which is outside of its bounds. The following animation shows RedRectangle placed outside of the bottom of its bounds with a Y Units of Pixels from Bottom.
Notice that if RedRectangle is moved so that it is inside the bounds, it can affect the absolute height of the parent. As RedRectangle is moved into the bounds, the parent grows to accommodate the desired RedRectangle Y value.
If a child is a Text instance using a Y Origin of Baseline and a Y Units of Pixels from Bottom, then portions of the text which fall below the baseline are ignored by the parent's height.
A parent ignores its child if the child uses a Y Units of Percentage of Parent Height because this also creates a circular dependency (parent height depends on child position, child position depends on parent height).
If a parent sets its Height Units to Relative to Children, then it resizes itself to contain its children. Normally, the height of the entire parent is determined by the child which needs the most space vertically. If the parent uses an Auto Grid Vertical layout, then the children control the size of the cells as well as the entire parent. Since all cells must be the same size, the child which needs the most amount of space vertically determines the height of all cells.
For example, the following image shows a four by four grid, each containing one white rectangle. The first rectangle has an Absolute Width and Height of 100, so each cell is sized to be 100x100. Note that the other rectangles are 50x50.
The largest child determines the cell size for all other children. Therefore, if a child is moved or resized so it outgrows its cell, then the parent height adjusts in response.
The height of a container is determined by the height of the largest cell multiplied by the number of rows. For example, the following container has 4 columns and 3 rows, resulting in 12 cells. The height of the grid is based on 3 rows multiplied by the height of the largest cell.
If children are removed from the container, the container's height does not change - the Auto Grid Vertical Cells value determines the number of rows when calculating height, whether the cells contain children or are empty.
Since Auto Grid Vertical Cells acts only as a minimum and not maximum, more children can be added and the container expands to support the newly-added children.
Setting a grid's Height value to a non-zero value increases the height of the on top of what is needed to contain its children. This additional height is distributed evenly to all cells, resulting in additional spacing between each child.
For example, the following 3x3 grid contains children with an absolute height of 50. The grid's Height Units is set to Relative to Children. Notice that as the grid's Height increases, it grows vertically. This vertical growth results in a larger cell size, so each child is spaced apart.
The term "children" can refer to:
Instances added to a parent, such as ColoredRectangles added to a Container
Individual letters in a Text instance - each letter and line of text can expand the height of its parent
The following animation shows a Text instance which has its Height Units set to Relative To Children. As more lines of text are added, the Text automatically expands in size.
The height of a Text instance using Relative to Children depends on the number of lines displayed by the Text instance and the maximum line height given the current font properties. Therefore, the height of a Text stance remains the same regardless of the contents of a single line.
For example, the following image contains multiple Text instances. Each has a single line of text, but the line of text differs in the height of each character. Notice that the texts are all the same height even though the contents of their lines differ.
We can observe the absolute height of a Text instance by mousing over one of the handles for resizing vertically.
In this case, the height is 41 pixels tall. This is based on the lineHeight as defined on the .fnt file. The image above is using an Arial 36 font which has a lineHeight value of 41 pixels.
Relative to Max of Children or Parent sizes an element to whichever is larger — its parent's height or the height needed to contain its children. The Height value acts as padding on the children side, the same as Relative to Children. A Height of 0 means the element is exactly the larger of its parent's height or its children's bounds.
This unit is most useful when multiple siblings all use Relative to Max of Children or Parent. In this case, the sibling with the tallest content drives the parent's height, which in turn sets the height of all shorter siblings. This creates a row of elements that always match each other's height regardless of their individual content.
For example, consider a horizontal row of text frames (colored rectangles each containing a Text instance). Each frame uses Relative to Max of Children or Parent for its Height Units. When one Text instance wraps to more lines and becomes taller, that frame grows to fit its content. Because the taller frame pushes the parent to grow, all other frames also grow to match — keeping the row uniform.
Without this unit, you would need to either set a fixed height on all frames (which cannot adapt to content) or use Relative to Children on each frame (which makes each frame a different height based on its own content).
Percentage of Width adjusts the object's effective height so it remains proportional to the Width value multiplied by the Height value (as a percentage). For example, if a Height value of 200 is entered, then the effective height is 200% (2x) of the Width.
The following image shows a child ColoredRectangle with a Height of 200 Percentage of Other Dimension. In this image, the Width value is 50 units, so the effective height is 100 units:
can select a Height Units called Percentage of File Height, which sets the height of the Sprite according to the file that it is displaying. This is the default Height Units for Sprites.
The following image shows a child Sprite with 200 Percentage of Source File Height, which means it draws two times as tall as its source image:
This value depends on the Sprite's Texture Height property, so changing Texture Height also changes the Sprite's absolute height.
Sprites can select a Height Unit called Maintain File Aspect Ratio Height which sets the height of the sprite so its aspect ratio matches its source file multiplied by the Height value. Usually Maintain File Aspect Ratio Height is used with a Height value of 100 so that the Sprite shows is source file at the correct aspect ratio.
When this value is used, a Sprite's Width can be changed resulting in its absolute height also changing.
When using Maintain File Aspect Ratio Height, the Sprite's absolute height depends on the Sprite's Texture Height property.
Absolute Multiplied by Font Scale is a value which multiplies an object's Height value by the global Font Scale value. This can be used to create heights which are responsive to font scale for devices which may have variable text sizes.
The Font Scale value can be adjusted in the Editor tab to preview different global Font Scale values. When a Gum project is loaded at runtime, the runtime may apply a Font Scale value such as using the Text size from Windows.
The global Font Scale value is set to 4, so the rectangle in the following image is drawn at an effective height of 200 pixels.
The Width Units variable controls how a unit is horizontally sized, which may be relative to its parent. By default elements uses Absolute width, where each unit represents 1 pixel of width in absolute terms. When using Absolute, an object ignores its parents' effective width.
The following shows a child with 50 Absolute Width:
The following image shows a child ColoredRectangle with -10
Percentage of Parent HeightRelative to Parent


Ratio of Parent set to 1

Height Units of Ratio of Parent

Height value of 3
Ratio of Parent Height of 0
Absolute ColoredRectangle with 80 Height
Height changes all sibling heights

Stack Spacing reduces the available ratio space for all children






Pixels From Bottom upward can make the parent grow to accommodate the child's Y value

Y Units of Percentage of Parent Height results in the child ignored
Relative to Children height





Height Units is set to Relative To Children





Percentage of Other Dimension Height of 200

exture Height adjusts its absolute height when using Percentage of File Height
Width when using Maintain File Aspect Ratio Height also adjusts absolute height
Width or Texture Height affects the Sprite's absolute height


Relative to ParentWidthIf an instance does not have a parent, then it uses the canvas size when using a Width Units of Relative to Parent.
Relative to Parent with no direct parentThe following shows a child ColoredRectangle with 100 Percentage of Parent Width, which means it has 100% of the effective width of its parent. Note that 100 Percentage of Parent is the same as 0 Relative to Parent:
If an object does not have a parent, then the width of the canvas is used.
Ratio of Parent can be used to fill available space or to share available space with other objects using a ratio. It behaves similar to a Height Units of Ratio of Parent, but operates horizontally rather than vertically. For a more detailed discussion of Ratio of Parent, see the Height Units page.
Ratio of Parent is usually used with a parent that has its Children Layout set to Left to Right Stack or Top to Bottom Stack. For more information, see the Children Layout page.
The following image shows a child ColoredRectangle with 50 Relative to Children Width, which means that it is sized 50 pixels wider than is necessary to contain its children. Since the rectangle has no children, this is the same as having 50 Absolute Width:
Relative to Children can be used to size an object based on the position and sizes of a parent's children. The following animation shows a container with 0 Relative to Children Width, which means that its effective width is set just large enough to contain its children. Notice that if the children are moved, the parent's effective width adjusts. Both children are considered so the container adjusts its width according to the right-most side of either child:
Width Units of Relative to ChildrenA non-zero Width when using Relative to Children can be used to add additional padding to a parent container. The following animation shows how changing the Width variable can adjust the absolute width relative to children:
Relative to ChildrenRelative to Children results in effective width dynamically adjusting in response to changes on a container's children. The following animation shows a container with Children Layout of Left to Right Stack. Adding additional children expands the container automatically:
A parent container can ignore its children when it determines its absolute width when using a Width Units of Relative to Children if any of the following are true:
The child's Ignored By Parent Size is true.
The child's width depends on its parent's width. This circular dependency is resolved by the parent ignoring this child.
The child is explicitly positioned outside of the parent's bounds
The child's X Units is Percentage of Parent Width
If a child has its Ignored By Parent Size set to true, then the parent ignores this child when calculating its own size. For more information, see the Ignored By Parent Size page.
If a child's width depends on the parent, then the child is ignored by the parent. Once the parent has determined its own width, then the child is sized according to the parent. This type of circular dependency is common when adding background visuals to a container.
For example consider a container with two children - BlueRectangle and YellowRectangle - with the following variables:
BlueRectangle X = Pixels from Left
BlueRectangle Width Units = Absolute
YellowRectangle Width Units = Relative to Parent
Only YellowRectangle depends on its parent.
Since BlueRectangle's absolute width value does not depend on the parent, the parent can use BlueRectangle's absolute width when calculating its own absolute width. Since YellowRectangle depends on the parent, the parent ignores the YellowRectangle. Instead, YellowRectangle depends on the parent container's absolute width for calculating its own absolute width. This in effect creates a situation where BlueRectangle affects the width of both its parent and also its YellowRectangle sibling.
A parent does not consider a child if the child is explicitly positioned outside of the parent's bounds. This can happen if the child's X Units and X values result in the child being drawn outside of the parent's bounds
If a child has X Units of Pixels from Left and its X value pushes the child out of the left of the parent, then the portion that is outside of the left of the parent is ignored. The BlueRectangle in the following image has an absolute width of 50. Its X value is -20, so only 30 pixels are used to determine the parent's effective height.
Similarly, if a child uses an X Units of Pixels from Right then the parent does not consider the width of any portion which is outside of its bounds. The following animation shows RedRectangle placed outside of the right of the container's bounds with a X Units of Pixels from Right.
Notice that if RedRectangle is moved so that it is inside the bounds, it can affect the absolute width of the parent. As RedRectangle is moved into the bounds, the parent grows to accommodate the desired RedRectangle X value.
Pixels from Right can make the parent grow to accommodate the child's X valueA parent ignores its child if the child uses an X Units of Percentage of Parent Width because this also creates a circular dependency (parent width depends on child position, child position depends on parent width).
X Units of Percentage of Parent Width result in the child ignoredIf a parent sets its Width Units to Relative to Children, then it resizes itself to contain its children. Normally the width of the entire parent is determined by the child which needs the most space horizontally. If the parent uses an Auto Grid Horizontal layout, then the children control the size of the cells rather than the entire parent. Since all cells must be the same size, the child which needs the most amount of space horizontally determines the width of all cells.
For example, the following image shows a four by four grid, each containing one white rectangle. The first rectangle has an Absolute Width and Height of 100, so each cell is sized to be 100x100. Note that the other rectangles are 50x50.
Relative to Children widthThe largest child determines the cell size for all other children. Therefore, if a child is moved or resized so it outgrows its cell, then the parent width adjusts in response.
The width of a container is determined by the width of the largest cell multiplied by the number of columns. For example, the following container has 3 columns and 4 rows, resulting in 12 cells. The width of the grid is based on 3 columns multiplied by the width of the largest cell.
If children are removed from the container, the container's width does not change - the Auto Grid Horizontal Cells value determines the number of columns when calculating width, whether the cells contain children or are empty.
Since Auto Grid Horizontal Cells acts only as a minimum and not maximum, more children can be added and the container expands to support the newly-added children.
Setting a grid's Width value to a non-zero value increases the width of the container on top of what is needed to contain its children. This additional width is distributed evenly to all cells, resulting in additional spacing between each child.
For example, the following 3x3 grid contains children with an absolute width of 50. The grid's Width Units is set to Relative To Children. Notice that as the grid's Width increases, it grows horizontally. This horizontal growth results in a larger cell size, so each child is spaced apart.
Setting a Text instance's Width Units to Relative to Children results in the Text object adjusting according to its text contents. In other words if a Text's Width Units is set to Relative To Children, then the words in the Text do not wrap.
For example, setting the Width Units to Relative to Children and setting the Width to 0 results in the Text object automatically adjusting its actual width according to the text it contains.
Relative to Max of Children or Parent sizes an element to whichever is larger — its parent's width or the width needed to contain its children. The Width value acts as padding on the children side, the same as Relative to Children. A Width of 0 means the element is exactly the larger of its parent's width or its children's bounds.
This unit is most useful when multiple siblings all use Relative to Max of Children or Parent. In this case, the sibling with the widest content drives the parent's width, which in turn sets the width of all narrower siblings. This creates a column of elements that always match each other's width regardless of their individual content.
For example, consider a vertical menu where each menu item contains a Text instance. Each menu item uses Relative to Max of Children or Parent for its Width Units. When one menu item has longer text, that item grows to fit its content. Because the wider item pushes the parent to grow, all other menu items also grow to match — keeping the menu uniform.
Without this unit, you would need to either set a fixed width on all menu items (which cannot adapt to content) or use Relative to Children on each item (which makes each item a different width based on its own text).
Percentage of Height adjusts the object's effective width so it remains proportional to the effective height value multiplied by the Width value (as a percentage). For example, if a Width value of 200 is entered, then the effective width is 200% (2x) of the height.
The following image shows a child ColoredRectangle with a Width of 200 Percentage of Height. In this image, the Height value is 50 units, so the effective width is 100 units:
Sprites can select a Width Unit called Percentage of File Width, which sets the width of the Sprite according to the file that it is displaying. This is the default Width Unit for Sprites.
The following image shows a child Sprite with 200 Percentage of Source File Width, which means it draws two times as wide as its source image:
When using Percentage of Source File Width, the Sprite's absolute width depends on the Sprite's Texture Width property.
Texture Width adjusts its absolute height when using Percentage of File WidthFor more information, see the Sprite Texture Address page.
Sprites can select a Width Unit called Maintain File Aspect Ratio Width, which sets the effective width of the Sprite so that its aspect ratio matches its source file multiplied by the Width value. Usually Maintain File Aspect Ratio Width is used with a Width value of 100 so that the Sprite shows is source file at the correct aspect ratio.
When this value is used, a Sprite's Height can be changed resulting in its absolute width also changing.
Height when using Maintain File Aspect Ratio Width also adjusts absolute widthWhen using Maintain File Aspect Ratio Width, the Sprite's effective width depends on the Sprite's Texture Width property.
Height or Texture Width affects the Sprite's effective widthAbsolute Multiplied by Font Scale is a value which multiplies an object's Width value by the global Font Scale value. This can be used to create widths which are responsive to font scales for devices which may have variable text sizes.
The Font Scale value can be adjusted in the Editor tab to preview different global Font Scale values. When a Gum project is loaded at runtime, the runtime may apply a Font Scale value such as using the Text size from Windows.
The global Font Scale value is set to 4, so the rectangle in the following image is drawn at an effective width of 200 pixels.

Variable References allows any variable on an instance or component to reference other variables. These other variables can be on the same instance or component, a different instance, or even variables from a different component.
One common use of Variable References is to create a centralized style component which can be referenced throughout a Gum project.
Variables which are assigned through Variable References cannot be directly set on the instance - the value obtained through the reference overwrites any custom value. For example, the reference Height = Width results in Height being read-only and depending on Width. Note that this is using a shorthand variable assignment which is discussed in later sections.





























Variable References can contain multiple lines. Each line is a separate variable reference. Each variable reference uses the following syntax:For example, to assign a Component's X value to a different component's X value, the following syntax could be used:
X references the X value in OtherComponent. Note that X could be the X value on any component or any instance inside of a component:
Spaces are optional around the equals sign, but spaces are not allowed in variable names. The following lines are okay:
However, the following is not allowed:
Lines can be commented out to disable the reference. If Gum encounters a scripting error, it will automatically comment out lines as well so that you can make corrections:
An Instance can reference its own Component's X value by using the qualified name:
An instance or component can reference the variable of another instance in the same component by using the name of the instance. The name of the containing component or screen is not required if the instances are both in the same component or screen:
Components and instances can reference variables that are contained within instances of other components. In this case the name of the referenced instance is appended to the qualified name of the Screen or Component:
Elements and Screens inside subfolders can be referenced. The subfolder path is included with forward slashes:
The right side can be a variable in a Screen, although this isn't too common in practice:
Similarly, variables on Standards can also be referenced. This is also quite rare, since this modifying the Standard element also has side effects on every other instance that is of the same type:
Although it's common for variables to reference the same variable on a different object (such as X being set to another object's X value), this is not a requirement. For example, the following lines are valid:
Instances can reference their own variables, but these must be qualified. For example, ColoredRectangleInstance can assign its Width to equal its own Height. Note that Gum will extend shorthand code as shown in a later section:
Variables can be assigned to constant values, essentially locking the value:
Math operations can be used in variable assignments. This includes add, subtract, multiply, divide, and parenthesis to control order of operations:
Math operations can reference both constant values (1, 2, 3) or other variables:
Variable references support conditional (ternary) expressions, comparison operators, and logical operators. These can be combined to drive variable values from boolean conditions or to switch between values based on other variables.
A conditional expression uses the C# cond ? a : b syntax. If cond evaluates to true, the result is a; otherwise the result is b. The condition can be a boolean variable or a comparison:
Just like simple variable references, the right side can be fully qualified to point at another element:
Ternary expressions can be nested. Use parenthesis to make the order of evaluation clear:
The operators ==, !=, <, >, <=, and >= can be used to compare values. The result is a bool, so comparisons are most often used as the condition of a ternary or as the right side of a bool assignment:
The logical operators && (and) and || (or) combine two bool values into a single bool. Both operands must be bool:
The ! operator inverts a bool value:
Variable references can drive a component's categorical state by assigning to <CategoryName>State. The right side must resolve to a string matching one of the state names defined in that category. This is useful for switching visual states from another instance's variable. For example, on a button-derived component with a ButtonCategory containing Enabled and Disabled states:
If the right side is a literal string, Gum validates it against the category's state names and comments out the line if there is no match.
Standard Forms behaviors (Button, TextBox, Slider, and so on) can use a category-state assignment to drive a visual state from a Behavior Property — a property in the Variables tab's Behavior category that also flows through to the runtime Forms control. See for what these are.
For example, a TextBox-derived component previews its multi-line layout at design time using a reference like:
This works the same as any other category-state assignment — the driven state is read-only, and changing TextWrapping or AcceptsReturn in the Behavior category updates the preview immediately. The only difference is where the right-hand variable comes from: a Behavior Property instead of an ordinary instance variable.
These references ship pre-authored on the standard Forms behaviors, so you typically won't write one yourself unless you're customizing a Forms component's default visual or authoring a custom behavior.
Variables whose type is an enumeration — such as ChildrenLayout, or unit and alignment types like XUnits and WidthUnits — can be assigned using the enum value's name as a string. Gum converts the name to the matching enum value:
Because the right side is a string, an enum can also be selected with a ternary or driven from another variable. For example, a container can switch its layout direction based on a bool:
The name must match one of the enum's values; if it does not, the assignment is not applied. An enum variable can also be assigned from another variable of the same enum type, or from the enum's underlying integer value:
Numeric variable types can be mixed. For example, Red is typically an int value (whole number), while X is a float (supports decimals). Gum automatically casts the variable appropriately:
Gum automatically casts any value to a string (text). For example, a Text's Text variable could be assigned to its own Y value:
Strings can be concatenated (combined) using the + operator:
Gum cannot convert unrelated types, including different Units. For example, the following would be commented out by Gum:
Variable references can include custom variables, both on the left and right side. Custom variables can be combined with variable references to create flexible layouts. For more information on using custom variables, see the .
As mentioned above, fully qualified assignments are allowed in any context. For example, a component can reference its own qualified variables:
Components do not need to qualify their own variables. They can reference them without any qualification. Therefore, the following variable reference is equivalent to the fully-qualified reference above:
Similarly, the following two variable references are equivalent assuming ContainedInstance is part of the component with the reference:
Instances must qualify their own variables. See for what an unqualified name means instead:
Gum will automatically qualify assignments when an instance is selected. In other words, X = Y gets qualified to X = SameInstance.Y if SameInstance is the owner of the variable. This automatic qualification makes it easy for an instance to reference its own values. The following animation shows how the Y and Height values become qualified to the instance after tabbing out of the Variable Reference text box.
Complex assignments are automatically qualified as well.
The left side of an assignment can be omitted if referencing the same variable on another instance or component. For example, by typing OtherInstance.YUnits , Gum automatically expands the reference to YUnits = OtherInstance.YUnits .
Note that this only works when assigning one variable directly to another variable. Complex assignments will not be prefixed.
Assigning color values is a common part of styling, so to help with this situation, Gum also expands the "Color" variable into all three components when the Variable References text box loses focus. For example, the following text can be used to assign all three values at once:
When the Variable References box loses focus, this is expanded to the following assignments:
As shown above, Variable References can be used to assign one variable to another. If a variable is referenced, then the variable cannot be manually assigned. The Variable Reference takes priority. For example, if an object references the Red, Green, and Blue variables, then those values cannot be manually set on the object. The values appear disabled and text indicates why they are read-only.
Typing a variable name can be tedious, especially when referencing a variable in a different Screen or Component. Qualified variable names can be obtained by right-clicking on the variable name in Gum and selecting the Copy Qualified Variable Name option. This can then be pasted in the Variable References box of any other object.
The following example creates a Styles component which contains a color value which is referenced by objects in a MainMenu Screen.
Any component can serve as a centralized location for styling, but we use the name Styles by convention.
The Styles component can contain as many objects as are needed to style your project. Additional objects can be added to help indicate how things are used visually. For example, we include a Text object to indicate the red color is the Primary Color.
The color value can be referenced by any other object including objects in different screens or components.
To add a variable reference:
Select the object which should have a variable reference
Click inside the Variable References text box
Type the variable reference. The format of the variable reference is
{VariableName} = {Components or Screens}/{ComponentOrScreenName}.{InstanceName}.{InstanceVariable}
For example, to reference the Red variable in the Styles component, the syntax is
Red = Components/Styles.PrimaryColor.Red\
Since color values have three components (Red, Green, and Blue), then all three components must be referenced. In this example, the background can reference the three colors with the following assignment text:
The types of the objects that contain the Variable References or which are being referenced do not matter. For example, a Text object could have its color values depend on the color values defined by a ColoredRectangle in the Styles component.
Once Variable References are set, the referenced instances (instances in Styles) can be changed and the changes will immediately propagate throughout the entire project.
The example above references a Styles component from one object at a time. You can go further and build a reusable, semantic color palette (for example: White, Gray, Black, Primary, Success, Warning, Danger) that any instance in your project can select by name, without hardcoding a color anywhere outside of the Styles component.
This combines two features already covered elsewhere:
A category per Standard Element - Select the NineSlice, Sprite, or Text Standard Element and add a category (for example ColorCategory) with one state per palette name. See for how to create categories and states.
A Variable Reference per state - Select each state in the category and use the Color Expansion shorthand to point it at the matching instance in your Styles component:
Repeat this for every state in the category (White, Gray, Primary, Success, and so on), pointing each one at its matching Styles instance. Because the reference lives on the Standard Element itself, every instance of that Standard Element across your entire project shares the same palette.
Repeat the category on each Standard Element that needs coloring (NineSlice, Sprite, Text). Once this is set up, any instance anywhere in the project can select a palette color with a single instead of a color reference:
{Variable} = {Components or Screens}/{ComponentOrScreenName}.{Instance}.{Variable}X = Components/OtherComponent.XX = Components/OtherComponent.XY=Components/OtherComponent.Y
Width = Components/OtherComponent.Width// Spaces are not allowed, so Gum would comment this reference:
X Units = Components/OtherComponent.X Units// This is considered a comment so it will not run
// Neither will this:
// X = Components/OtherComponent.YX = Components/ComponentContainingThisInstance.XWidth = OtherInstanceInSameComponent.WidthRed = Components/StyleComponent.PrimaryColorRectangle.RedXUnits = Components/ComponentFolder/ComponentInFolder.XUnitsGreen = Screens/MainMenuGum.ColoredRectangleInstance.GreenYUnits = Standards/Text.YUnitsY = OtherInstance.X
Width = Components/OtherComponent.HeightWidth = ColoredRectangleInstance.HeightX = 100
Text = "Hello"
Visible = trueY = (TitleText.Y + 2) * 7 - 4Width = (OtherInstance.Height * 3) + 10Width = TitleText.Visible ? 200 : 100
X = Background.Width > 500 ? Background.X : 0Width = Components/AppState.IsExpanded ? 400 : 200Width = Container.Width > 500 ? 300 : (Container.Width > 250 ? 200 : 100)Visible = Background.Width > 100
Width = ScoreText.Y >= TitleText.Y ? 300 : 100Visible = ToggleButton.Visible && ContentArea.Visible
Visible = ErrorIcon.Visible || WarningIcon.VisibleVisible = !LoadingSpinner.VisibleButtonCategoryState = Background.Visible ? "Enabled" : "Disabled"LineModeCategoryState = TextWrapping == "Wrap" ? "Multi" : (AcceptsReturn ? "Multi" : "Single")ChildrenLayout = "LeftToRightStack"ChildrenLayout = IsHorizontal ? "LeftToRightStack" : "TopToBottomStack"ChildrenLayout = OtherContainer.ChildrenLayoutX = ColoredRectangleInstance.Red
Green = ColoredRectangleInstance.YText=TextInstance.YText="My Position is " + TextInstance.X + ", " + TextInstance.Y//WidthUnits = TextInstance.HeightUnitsX = Components/SameComponent.YX = YY = Components/SameComponent.InstanceInComponent.Y
// is equivalent to:
Y = InstanceInComponent.YX = SameInstance.YComponents/Styles.PrimaryColor.ColorRed = Components/Styles.PrimaryColor.Red
Green = Components/Styles.PrimaryColor.Green
Blue = Components/Styles.PrimaryColor.BlueRed = Components/Styles.PrimaryColor.Red
Green = Components/Styles.PrimaryColor.Green
Blue = Components/Styles.PrimaryColor.BlueComponents/Styles.PrimaryColor.ColorColorCategoryState = "Primary"Skipping the qualification isn't an error, it's a different reference. X = Height on an instance resolves Height against the containing component, not the instance. To reference the instance's own Height, qualify it: X = ColoredRectangleInstance.Height.
The Variable References grid protects you from this by auto-qualifying bare names to the selected instance when you tab out, so this mix-up mostly only happens in hand-edited or generated project XML.
Gum treats the prefixes Components/, Screens/, and Standards/ as special prefixes and does not consider this to be a division operator. Therefore, you should not name variables Components, Screens, or Standards as these are reserved words. Other variable references can freely use the forward slash character to create division.
For example, the following two lines of code show the difference between a simple variable reference assignment and a division operation:
Add a screenshot showing the ColorCategory states on the NineSlice Standard Element, each with a Color Expansion reference into the Styles component.












// This is a direct assignment setting X to
// the X value on Components/OtherComponent:
X = Components/OtherComponent.X
// This is a division operation setting X to
// the result of dividing the CustomVariable by OtherComponent.X
X = CustomVariable/OtherComponent.X