Gum in Code
Introduction
Gum Code-Only
using Gum.Forms.Controls;
using Gum.Wireframe;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MonoGameGum;
using System;
namespace MonoGameAndGum;
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
GumService GumUI => GumService.Default;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
GumUI.Initialize(this, Gum.Forms.DefaultVisualsVersion.V3);
var stackPanel = new StackPanel();
stackPanel.AddToRoot();
stackPanel.Spacing = 6;
stackPanel.Anchor(Anchor.Center);
var button = new Button();
stackPanel.AddChild(button);
button.Text = "Click Me";
button.Click += (s, e) =>
{
button.Text = DateTime.Now.ToString();
};
var textBox = new TextBox();
textBox.Width = 150;
stackPanel.AddChild(textBox);
var listBox = new ListBox();
stackPanel.AddChild(listBox);
for(int i = 0; i < 10; i++)
{
listBox.Items.Add("Item " + i);
}
base.Initialize();
}
protected override void Update(GameTime gameTime)
{
GumUI.Update(gameTime);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
GumUI.Draw();
base.Draw(gameTime);
}
}

Gum Tool Projects in Code

Last updated
Was this helpful?

