Skip to content

77 game-dev skills for AI coding agents — Godot, Unity, Unreal, Phaser, PixiJS, three.js, Bevy, pygame, LÖVE, Roblox. Portable SKILL.md Agent Skills (the format Anthropic launched as Claude Skills), with a router that loads the right skill for your engine and task. Runs in Claude Code, Cursor, Kiro, Codex, Copilot, Gemini CLI and more.

fix(game-ui-ux): stretch-aware safe area, real focus trapping and screen stack, Input System UI module, XAG text and contrast floors

Kiro Crew1b71e6315900
diff --git a/skills/disciplines/game-feel/references/feedback-recipes.md b/skills/disciplines/game-feel/references/feedback-recipes.md
index 6abb720..232ccd4 100644
--- a/skills/disciplines/game-feel/references/feedback-recipes.md
+++ b/skills/disciplines/game-feel/references/feedback-recipes.md
@@ -91,7 +91,9 @@ feeling either dead (under-juiced) or exhausting (everything maxed).
- **Reduce screen shake** (scale trauma output by a 0–100% setting, default ~60–80%).
- **Reduce/disable flashing** (photosensitivity) — replace white flashes with a static tint.
Even with flashing on, keep any large-area flash at or under three flashes in any one-second
- window (WCAG 2.3.1 general flash threshold; Xbox Accessibility Guideline 118, Photosensitivity).
+ window ([WCAG 2.3.1](https://www.w3.org/WAI/WCAG22/Understanding/three-flashes-or-below-threshold.html)
+ general flash threshold; [Xbox Accessibility Guideline 118](https://learn.microsoft.com/en-us/xbox/accessibility/xbox-accessibility-guidelines/118),
+ Photosensitivity).
- **Reduce camera motion** — cut shake roll and zoom punches.
These pair with `game-ui-ux` (settings menu) and `input-systems` (accessibility section).
diff --git a/skills/disciplines/game-ui-ux/SKILL.md b/skills/disciplines/game-ui-ux/SKILL.md
index c846467..c7088f7 100644
--- a/skills/disciplines/game-ui-ux/SKILL.md
+++ b/skills/disciplines/game-ui-ux/SKILL.md
@@ -75,19 +75,24 @@ func _ready() -> void:
# Unity 6.3 LTS — Canvas > CanvasScaler:
# UI Scale Mode = "Scale With Screen Size", Reference Resolution = 1920x1080,
# Match = 0.5 (blend width/height) — pick 1.0 if your HUD is height-critical.
+# Unity 6.3 LTS — UI Toolkit: the same three settings live on the PanelSettings asset
+# (Scale Mode = Scale With Screen Size, Reference Resolution, Screen Match Mode/Match).
```
### 3. Safe-area inset for notches / overscan
```gdscript
-# Godot 4.7. Inset a margin container to the OS-reported safe rect (phones, TVs).
+# Godot 4.7. Inset a MarginContainer to the OS safe rect. Only Android and iOS report a real
+# safe area; elsewhere Godot returns the screen's usable rect, so desktop margins are ~0.
func _apply_safe_area() -> void:
- var safe: Rect2i = DisplayServer.get_display_safe_area()
- var win := DisplayServer.window_get_size()
- $Margin.add_theme_constant_override("margin_left", safe.position.x)
- $Margin.add_theme_constant_override("margin_top", safe.position.y)
- $Margin.add_theme_constant_override("margin_right", win.x - safe.end.x)
- $Margin.add_theme_constant_override("margin_bottom", win.y - safe.end.y)
+ var safe := Rect2(DisplayServer.get_display_safe_area()) # screen pixels
+ var win := Rect2(Rect2i(DisplayServer.window_get_position(), DisplayServer.window_get_size()))
+ var inner := safe.intersection(win)
+ var to_ui := get_viewport_rect().size / win.size # window pixels -> UI units under stretch
+ $Margin.add_theme_constant_override("margin_left", int((inner.position.x - win.position.x) * to_ui.x))
+ $Margin.add_theme_constant_override("margin_top", int((inner.position.y - win.position.y) * to_ui.y))
+ $Margin.add_theme_constant_override("margin_right", int((win.end.x - inner.end.x) * to_ui.x))
+ $Margin.add_theme_constant_override("margin_bottom", int((win.end.y - inner.end.y) * to_ui.y))
# Unity 6.3 LTS: read Screen.safeArea (Rect in pixels) and set a panel's anchorMin/anchorMax to
# safeArea.position / (position+size) normalized by Screen.width/height.
```
@@ -95,13 +100,16 @@ func _apply_safe_area() -> void:
### 4. Gamepad/keyboard focus (UI is unusable on a controller without it)
```gdscript
-# Godot 4.7. Give each screen a default focus and wire neighbors so a stick/d-pad walks it.
+# Godot 4.7. Give each screen a default focus; Godot guesses neighbors from layout, so set
+# them only where its guess is wrong (grids, wrap-around, skipping a disabled row).
func _on_screen_shown() -> void:
$PlayButton.grab_focus() # always focus SOMETHING on open
-$PlayButton.focus_neighbor_bottom = $SettingsButton.get_path()
-$SettingsButton.focus_neighbor_top = $PlayButton.get_path()
-# Unity 6.3 LTS: EventSystem.SetSelectedGameObject(playButton) on enable; set each Selectable's
-# Navigation (Explicit or Automatic). RIGHT: a control is focused on open. WRONG: nothing
+ $PlayButton.focus_neighbor_bottom = $SettingsButton.get_path()
+ $SettingsButton.focus_neighbor_top = $PlayButton.get_path()
+# Unity 6.3 LTS uGUI: EventSystem.SetSelectedGameObject(playButton) on enable; set each Selectable's
+# Navigation (Explicit or Automatic). With the Input System package, the EventSystem needs an
+# InputSystemUIInputModule, not the old StandaloneInputModule. UI Toolkit: call Focus() on the
+# first focusable element. RIGHT: a control is focused on open. WRONG: nothing
# selected → the gamepad does nothing and the player is stuck.
```
@@ -111,8 +119,8 @@ $SettingsButton.focus_neighbor_top = $PlayButton.get_path()
# RIGHT: HUD reacts to a signal; it updates only when health actually changes.
func _ready() -> void:
player.health_changed.connect(_on_health_changed) # emitted by gameplay
-func _on_health_changed(current: int, max: int) -> void:
- $HealthBar.value = float(current) / max
+func _on_health_changed(current: int, max_health: int) -> void:
+ $HealthBar.value = float(current) / max_health
# WRONG: func _process(dt): $HealthBar.value = player.hp / player.max_hp # polls every frame,
# couples UI to the player's internals, and runs work even when nothing changed.
```
@@ -129,12 +137,20 @@ func _on_health_changed(current: int, max: int) -> void:
- **Polling game state in `_process`/`Update`.** Couples UI to internals and wastes work. Push
updates via signals/events.
- **Tiny fixed font sizes.** Unreadable on a TV-at-distance or a small phone. Scale text with the
- UI and offer a text-size option.
+ UI and offer a text-size option. Xbox Accessibility Guideline 101 sets floors of 26 px at 1080p
+ on console/TV and 18 px at 1080p on PC, and asks for scaling up to 200% without losing content.
- **Menu flow as boolean flags** (`isPaused`, `inSettings`, …) becomes unmanageable. Use a
screen stack with push/pop.
- **Hardcoded English strings baked into layout.** Translations overflow buttons. Externalize
strings and let containers size to content (see `references/`).
- **Mouse-only or focus-only.** Support both; switching input device should not strand the user.
+- **Unity uGUI menu ignores the gamepad or throws on start** after switching Active Input
+ Handling to the Input System: the scene still has a `StandaloneInputModule`. Replace it with
+ `InputSystemUIInputModule` (the Inspector offers a one-click swap). UI Toolkit in Unity 6 reads
+ the project-wide UI actions directly and needs no module.
+- **A corner-anchored uGUI element grows off-screen** when its size changes (longer translated
+ text, a bigger text-size setting): its pivot was left at (0.5, 0.5), so it grows in every
+ direction. Set the pivot to the anchored corner or edge as well.
## References
diff --git a/skills/disciplines/game-ui-ux/references/layout-and-flow.md b/skills/disciplines/game-ui-ux/references/layout-and-flow.md
index 139caf1..57b7938 100644
--- a/skills/disciplines/game-ui-ux/references/layout-and-flow.md
+++ b/skills/disciplines/game-ui-ux/references/layout-and-flow.md
@@ -13,6 +13,7 @@ target **Godot 4.7** and **Unity 6.3 LTS**.
| Mode | `canvas_items` | UI scales with the window (vs `viewport` = pixel-exact, `disabled` = none) |
| Aspect | `expand` | shows more world/UI space on odd ratios; `keep` letterboxes |
| Scale | `1.0`+ | global UI multiplier |
+| Scale Mode | `fractional` / `integer` | `integer` keeps pixel-art UI crisp by scaling in whole steps |
Anchor HUD corners so `expand` puts the extra space where you want it. `keep_width`/`keep_height`
pin one axis for hard 16:9 designs.
@@ -57,31 +58,57 @@ Requirements for controller/keyboard usability:
focused control. Don't clear focus when the mouse moves.
```gdscript
-# Godot 4.7: trap focus inside a modal so the stick can't escape to the game behind it.
+# Godot 4.7: trap focus inside a modal so the stick can't escape to the menu behind it.
+var _prev_focus: Control
+
func open_modal() -> void:
_prev_focus = get_viewport().gui_get_focus_owner()
- $Modal.show(); $Modal/OK.grab_focus()
+ $Menu.focus_behavior_recursive = Control.FOCUS_BEHAVIOR_DISABLED # Godot 4.5+
+ $Menu.mouse_behavior_recursive = Control.MOUSE_BEHAVIOR_DISABLED
+ $Modal.show()
+ $Modal/OK.grab_focus()
+
func close_modal() -> void:
$Modal.hide()
+ $Menu.focus_behavior_recursive = Control.FOCUS_BEHAVIOR_INHERITED
+ $Menu.mouse_behavior_recursive = Control.MOUSE_BEHAVIOR_INHERITED
if is_instance_valid(_prev_focus): _prev_focus.grab_focus()
```
+Showing the modal and focusing its button is not a trap on its own: Godot's neighbor search
+still reaches visible controls behind it. The two `*_behavior_recursive` switches turn a whole
+subtree off without touching each button.
+
## 4. Screen/menu stack
Model screens as a stack of UI states; the top owns input and is visible. Push for overlays,
pop for "back". This generalizes pause, settings-over-pause, and confirm dialogs.
```gdscript
-# Godot 4.7 sketch (a CanvasLayer per screen; pausing the tree under an overlay):
+# Godot 4.7 sketch: screens are Controls under one CanvasLayer; only the top one is interactive.
+# Each screen scene marks its default control with the unique name %DefaultFocus.
var _stack: Array[Control] = []
+
func push(screen: Control) -> void:
- if _stack.size() > 0: _stack.back().set_process_input(false)
- _stack.append(screen); add_child(screen); screen.grab_focus_default()
+ if not _stack.is_empty():
+ _set_interactive(_stack.back(), false)
+ _stack.append(screen)
+ add_child(screen)
+ screen.get_node("%DefaultFocus").grab_focus()
+
func pop() -> void:
- var top := _stack.pop_back(); top.queue_free()
- if _stack.size() > 0:
- _stack.back().set_process_input(true); _stack.back().grab_focus_default()
-# Pause overlay: get_tree().paused = true and set the overlay's process_mode = ALWAYS.
+ var top: Control = _stack.pop_back()
+ top.queue_free()
+ if not _stack.is_empty():
+ var below: Control = _stack.back()
+ _set_interactive(below, true)
+ below.get_node("%DefaultFocus").grab_focus()
+
+func _set_interactive(screen: Control, on: bool) -> void:
+ # Godot 4.5+. set_process_input(false) would not do this: buttons get GUI input, not _input.
+ screen.focus_behavior_recursive = Control.FOCUS_BEHAVIOR_INHERITED if on else Control.FOCUS_BEHAVIOR_DISABLED
+ screen.mouse_behavior_recursive = Control.MOUSE_BEHAVIOR_INHERITED if on else Control.MOUSE_BEHAVIOR_DISABLED
+# Pause overlay: get_tree().paused = true and set the overlay's process_mode = PROCESS_MODE_ALWAYS.
```
This mirrors the state-stack idea in `love2d-core`'s `references/state-stack.md`, applied to UI.
@@ -97,7 +124,11 @@ This mirrors the state-stack idea in `love2d-core`'s `references/state-stack.md`
## 6. Accessibility (bake in, don't bolt on)
- **Text size option** and never hardcode tiny fonts; size to a percentage of reference height.
-- **Contrast & color independence:** don't encode state in color alone — add icon/shape/text.
+ Xbox Accessibility Guideline 101 floors: 26 px at 1080p (52 px at 4K) on console/TV, 18 px at
+ 1080p on PC, and player scaling up to 200% without clipping or lost meaning.
+- **Contrast & color independence:** text that carries gameplay information needs at least
+ 4.5:1 contrast with its background, large text and key visual elements at least 3:1 (Xbox
+ Accessibility Guideline 102). Don't encode state in color alone — add icon/shape/text.
Provide colorblind-safe palettes.
- **Scalable hit targets** for touch (≥ ~9 mm); padding around small buttons.
- **Reduce-motion / reduce-flashing** toggles (coordinate with `game-feel`).
@@ -111,3 +142,11 @@ This mirrors the state-stack idea in `love2d-core`'s `references/state-stack.md`
Avoid fixed-width buttons sized to English.
- Leave room for RTL mirroring and different number/date formats.
- Keep icons separate from text so only strings need translating.
+
+## Primary sources
+
+- [Godot 4.7: Multiple resolutions](https://docs.godotengine.org/en/4.7/tutorials/rendering/multiple_resolutions.html)
+- [Unity Input System 1.14: UI support](https://docs.unity3d.com/Packages/[email protected]/manual/UISupport.html)
+- [Xbox Accessibility Guideline 101: Text display](https://learn.microsoft.com/en-us/xbox/accessibility/xbox-accessibility-guidelines/101)
+- [Xbox Accessibility Guideline 102: Contrast](https://learn.microsoft.com/en-us/xbox/accessibility/xbox-accessibility-guidelines/102)
+- [Game Accessibility Guidelines](https://gameaccessibilityguidelines.com/)