DebugUI v0.1.0 Released

Hajime Hoshi
2025-04-05

DebugUI is a debugging UI library for Ebitengine. When developing games, you may sometimes need a debugging UI—for example, to display FPS or TPS, or to dynamically change in-game parameters. Writing code for mouse clicks, keyboard handling, and UI rendering for these tasks can be a hassle. DebugUI provides an easy-to-use debugging UI.

With DebugUI, you can handle complex parameter adjustments in a clean and organized way.

Before using DebugUI

Before using DebugUI

After using DebugUI

After using DebugUI

DebugUI uses an Immediate Mode API. For example, the following code shows how to display a window with a single button:

package main

import (
	"fmt"
	"image"
	"os"

	"github.com/ebitengine/debugui"
	"github.com/hajimehoshi/ebiten/v2"
	"github.com/hajimehoshi/ebiten/v2/ebitenutil"
)

type Game struct {
	debugui debugui.DebugUI

	count int
}

func (g *Game) Update() error {
	if _, err := g.debugui.Update(func(ctx *debugui.Context) error {
		ctx.Window("Test", image.Rect(60, 60, 160, 120), func(layout debugui.ContainerLayout) {
			ctx.Button("Button").On(func() {
				g.count++
			})
		})
		return nil
	}); err != nil {
		return err
	}
	return nil
}

func (g *Game) Draw(screen *ebiten.Image) {
	g.debugui.Draw(screen)
	ebitenutil.DebugPrint(screen, fmt.Sprintf("Count: %d", g.count))
}

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int) {
	return outsideWidth, outsideHeight
}

func main() {
	if err := ebiten.RunGame(&Game{}); err != nil {
		fmt.Fprintln(os.Stderr, err)
		os.Exit(1)
	}
}

This is what the screen looks like when you run it:

Example of using DebugUI with a single button

Example of using DebugUI with a single button

Key points:

For more complex examples, see the Ebitengine samples or the DebugUI examples.

Note that DebugUI is still at version 0, so breaking changes to the API may occur in the future.