Skip to content
Back to skills

Godot Ui

ASecurity

Godot UI: Control anchors and containers, themes, HUD and menus, gamepad focus, content scaling, localisation, fonts and long text.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentspythonrustgobashnode

Works with

  • cli

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add tipoLi5890/game-studio --skill godot-ui --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Godot Ui?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Godot Ui
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tipoli5890-godot-ui/badge)](https://www.skillsdirectory.com/skills/tipoli5890-godot-ui)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: godot-ui
description: >-
  Godot UI: Control anchors and containers, themes, HUD and menus, gamepad focus, content scaling,
  localisation, fonts and long text.
---

# godot-ui — Control nodes, themes and text

UI is a tree of `Control` nodes laid out by containers and styled by one `Theme`. The HUD lives on
a `CanvasLayer`, menus are reachable by gamepad, and every string is a key.

## Load what the situation needs

| The situation | Read |
|---|---|
| A HUD or a menu from scratch | *Start from the templates* below, then `reference/layout.md` §1-3 |
| A centred box that is not centred; anchors, offsets, grow direction | `reference/layout.md` §1 |
| Which container; size flags; a spacer that pushes labels apart | `reference/layout.md` §2 |
| The HUD scrolls with the camera, or swallows clicks | `reference/layout.md` §3 |
| Ultra-wide, portrait, 4K: stretch mode and aspect | `reference/layout.md` §4 |
| "The pad does nothing in the menu"; focus stuck, lost or never reaching a button | `reference/layout.md` §5 · `resources/menu_focus.gd` |
| Colours, fonts, button styles, one look everywhere | `reference/themes.md` · `templates/courier_theme.tres` |
| Chinese, Japanese or Korean text shows boxes | `reference/themes.md` §5 |
| Translations: CSV or PO, `tr()`, switching language, plurals | `reference/localisation.md` §1-4 |
| Text set from code stays in English after a switch | `reference/localisation.md` §1 · `resources/hud.gd` |
| German overflows the button; long text, wrapping, pseudolocalisation | `reference/localisation.md` §5 |
| Proving any of it without a window | *Checking it headless* below · `scripts/ui_probe.py` |
| Input actions, rebinding, touch | `godot-input` |
| Pausing the game behind the menu; changing scenes | `godot-scene-flow` |
| Draw order of the world below the HUD | `godot-2d-rendering` |

## Start from the templates

| File | What it is |
|---|---|
| `templates/courier_hud.tscn` | HUD (`CanvasLayer`) > HudRoot (full-rect, ignores the mouse, `hud.gd`, the theme) > a margin, a top bar with the parcels count and the timer; a hidden pause menu (`CenterContainer` > `PanelContainer` > `VBoxContainer` with `menu_focus.gd`) with Resume, Options and Quit |
| `templates/courier_theme.tres` | one default font size, button styles with a visible focus ring, a HudLabel type variation (outlined) |
| `resources/hud.gd` | sets the parcels and timer text with `tr()`, rebuilds it on every locale switch, falls back to English when a key is missing |
| `resources/menu_focus.gd` | wires focus neighbours and Tab order through a list, row or grid with wrap-around, skips disabled buttons, focuses the first (or last used) item whenever the menu is shown |

Copy `templates/` and `resources/` side by side into the project (the scene reaches the scripts
by `../resources/`), or re-point its two `ext_resource` paths. Feed it from the game:

```gdscript
@onready var hud: Control = $HUD/HudRoot
@onready var pause_menu: Control = $HUD/HudRoot/PauseMenu

func _on_parcel_picked() -> void:
	hud.parcels += 1                       # the setter refreshes the label

func _process(delta: float) -> void:
	hud.time_left -= delta

func open_pause_menu() -> void:
	pause_menu.visible = true              # menu_focus.gd grabs focus for Resume
```

## The rules that keep a UI working

1. **Anchor presets are applied at the current size.** Applying `PRESET_CENTER` to an empty box
   and then filling it leaves its top-left corner at the centre; set both grow directions to
   both, or use a `CenterContainer`.
2. **Containers own their children's layout.** Inside one, set size flags and
   `custom_minimum_size`, never anchors or positions.
3. **The HUD goes on a `CanvasLayer`**; full-screen layout roots ignore the mouse.
4. **Pick `canvas_items` stretch with `expand` aspect** for a game UI that reaches the edges of
   wide and tall screens; test at the base size, an ultra-wide and a portrait size.
5. **Focus is explicit.** Nothing is focused until code calls `Control.grab_focus`; a plain
   `VBoxContainer` does not wrap `ui_down`; a neighbour pointing at a hidden control goes
   nowhere. Every menu gets `menu_focus.gd` (or the same wiring), and focus must be drawn.
6. **Every string is a key.** Labels holding a bare key translate themselves; text built in code
   uses `tr()` and rebuilds on `NOTIFICATION_TRANSLATION_CHANGED`, with the label's own
   auto-translation off.
7. **Import before listing translations.** A CSV's `.translation` files exist only after the
   first `--import`; listing them in `project.godot` before that prints `ERROR:` lines.
8. **Ship a font for every script you translate into.** The default font has no CJK glyphs, and a
   system font that is there on one machine is missing on the next.

## Checking it headless

Layout, focus and text are all computed without rendering, so they can be checked in a headless
run. `scripts/ui_probe.py` writes a probe script outside the project, runs the scene and reports:

```bash
python3 scripts/ui_probe.py --project game --scene res://ui/courier_hud.tscn \
    --show HudRoot/PauseMenu --sizes 1152x648,2560x1080,720x1280 --locales en,fr,ja --pseudo 0.4
```

| Line | Means |
|---|---|
| `FAIL OFFSCREEN <size> <path>` | a visible control leaves the visible rect at that window size |
| `FAIL FOCUS_UNREACHABLE <path>` | no `ui_*` action leads to this focusable control from the start (the whole focus graph is walked) |
| `FAIL FOCUS_LOST <path> <action>` | that action left nothing focused |
| `FAIL UNTRANSLATED <locale> <path> <KEY>` | a key that locale does not translate |
| `FAIL ENGINE ...` | the scene prints `ERROR:` or `SCRIPT ERROR:` |
| `FOCUS_ORDER ui_down: A > B > C > A` | the walk, for the record |

Exit 0 pass, 2 a check failed, 3 nothing verified (no Godot, a timeout, no sentinel), 1 usage.
`--rects` and `--texts` print every rectangle and text, for a test that asserts positions.
Run the project's `--import` first. A headless window is 64 x 64: with stretch `disabled` that is
the whole visible rect, so always pass `--sizes` (the default is the project's base size).

What it cannot check: how anything looks. Colours, contrast, focus-ring visibility, font
sharpness and drawn overlap need a windowed run and a person.

`scripts/ui_probe.py --selftest` (needs `GODOT_BIN`) builds a project from these templates, imports
a CSV and loads a PO file, and proves: the template passes at two sizes and three locales with
pseudolocalisation; the parcels label reads `Parcels: 0`, `Colis : 0`, `荷物: 0`; `ui_down` walks
Resume, Options, Quit and wraps; the timer's right edge stays 24 px from the visible edge at two
window shapes; and an unreachable button, a label off the screen, an untranslated key and a
missing scene each fail with exit 2.

## Discipline

- **Test every menu with the pad path, not the mouse.** The probe's focus walk is the pad.
- **One theme, set high**; type variations over per-node overrides.
- **No sentence in a scene.** A literal English string in a `.tscn` is a string nobody
  translates.
- **Leave room.** Budget 40 % more width for translated text, and run `--pseudo 0.4`.
- **Keep the HUD dumb.** It shows values the game sets; it never reads game state by itself, so
  a test can drive it with numbers.

## Related skills

| Need | Skill |
|---|---|
| Actions, rebinding, touch, the input map the `ui_*` actions live in | `godot-input` |
| Pause, scene changes, the autoload that holds run state | `godot-scene-flow` |
| Draw order, 2D lights, shaders below the HUD | `godot-2d-rendering` |
| HUD art and icons | `codex-visual` |
| Running Godot headless and trusting the result | `godot-verify` |

Files in this skill

  • SKILL.md7.5 KB
  • reference/layout.md7.8 KB
  • reference/localisation.md5.4 KB
  • reference/themes.md4.1 KB
  • resources/hud.gd1.8 KB
  • resources/menu_focus.gd3.6 KB
  • scripts/ui_probe.py21.3 KB
  • templates/courier_hud.tscn2.7 KB
  • templates/courier_theme.tres2.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.