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(roblox): PreferredInput for focus and hints, UI styling and Device Simulator in ui

Kiro Crewac6111c0f7b7
diff --git a/skills/other-engines/roblox-ui/SKILL.md b/skills/other-engines/roblox-ui/SKILL.md
index bc264af..96365de 100644
--- a/skills/other-engines/roblox-ui/SKILL.md
+++ b/skills/other-engines/roblox-ui/SKILL.md
@@ -28,7 +28,8 @@ gameplay action mapping belongs to `input-systems`; server trust belongs to `rob
1. **Inspect before designing.** In Explorer, inventory existing `ScreenGui`s, UI modules,
fonts, colors, icon family, spacing, corners, strokes, animation timing, naming, and reusable
- components. Capture representative screenshots at two viewports. Extend that language.
+ components, including any `StyleSheet`/`StyleLink` styling, tokens and themes. Capture
+ representative screenshots at two viewports. Extend that language.
2. **Define ownership and lifecycle.** `StarterGui` is the authored template; Roblox clones it
into each player's `PlayerGui`. Decide whether each `ScreenGui` should persist across respawn
with `ResetOnSpawn = false`; never keep stale references to a destroyed clone.
@@ -46,7 +47,7 @@ gameplay action mapping belongs to `input-systems`; server trust belongs to `rob
7. **Polish with restraint.** Implement hover, pressed, selected, and disabled states. Animate
state changes, not decoration; honor `GuiService.ReducedMotionEnabled` and clean up tweens and
connections when the screen closes or is replaced.
-8. **Verify the real interface.** Use Device Emulator and Controller Emulator. Test desktop,
+8. **Verify the real interface.** Use Device Simulator and Controller Emulator. Test desktop,
narrow portrait, mobile landscape, tablet-like, and console/gamepad; then respawn. Record
clipping, overlap, text, scroll, safe-area, focus path, touch target, and lifecycle results.
@@ -123,28 +124,44 @@ local GuiService = game:GetService("GuiService")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
-local function openInventory()
- root.Visible = true
+local function usesDirectionalFocus(): boolean
+ local preferred = UserInputService.PreferredInput
+ return preferred == Enum.PreferredInput.Gamepad
+ or preferred == Enum.PreferredInput.MicroGamepad
+end
+
+local function focusFirstItem()
task.spawn(function()
RunService.RenderStepped:Wait() -- selection must be rendered and selectable
- if root.Visible and (UserInputService.GamepadEnabled
- or (UserInputService.KeyboardEnabled and not UserInputService.TouchEnabled)) then
+ if root.Visible and usesDirectionalFocus() then
GuiService.SelectedObject = firstItemButton
end
end)
end
+local function openInventory()
+ root.Visible = true
+ focusFirstItem()
+end
+
local function closeInventory()
GuiService.SelectedObject = nil
root.Visible = false
end
+-- Owned by the screen lifecycle; disconnect on teardown.
+local inputConnection = UserInputService:GetPropertyChangedSignal("PreferredInput"):Connect(function()
+ if root.Visible and GuiService.SelectedObject == nil then focusFirstItem() end
+end)
+
firstItemButton.Activated:Connect(function()
selectItem(firstItemButton:GetAttribute("ItemId"))
end)
```
-Prefer `Activated` over separate mouse/touch handlers. Set `NextSelectionUp/Down/Left/Right`
+Decide input-dependent UI from `UserInputService.PreferredInput`, which follows the player's
+primary device; `TouchEnabled`/`GamepadEnabled` are capabilities (a touch laptop reports touch)
+and `GetLastInputType()` thrashes. Prefer `Activated` over separate mouse/touch handlers. Set `NextSelectionUp/Down/Left/Right`
when automatic navigation is ambiguous, especially around grids, sidebars, and modals. A modal
must trap focus inside itself and restore a sensible selection when it closes.
@@ -185,8 +202,10 @@ Animate a panel or state boundary once. Do not independently bounce every descen
- Establish hierarchy through size, weight, contrast, grouping, and whitespace before adding
decoration. Use a small spacing scale and align to it.
-- Preserve the game's fonts, palette, icons, radii, and strokes. If none exist, define a compact
- token module; do not improvise per component.
+- Preserve the game's fonts, palette, icons, radii, and strokes. If the project uses UI styling,
+ change tokens and `StyleRule`s rather than per-instance properties; the Properties window
+ marks styled properties with ⚠ and names the style on hover. If nothing exists, define a compact token set (a token `StyleSheet` or module); do not improvise per
+ component.
- Use corners where the material/form calls for them, not on every nested `Frame`. Avoid nested
card-on-card shells, universal pills, arbitrary gradients/glows/shadows, neon outlines,
excessive transparency/blur, oversized headings, meaningless icons, and huge empty panels.
@@ -195,14 +214,14 @@ Animate a panel or state boundary once. Do not independently bounce every descen
- Motion communicates open/close, focus, confirmation, or spatial relationship. Keep it short,
interruptible, and subtle; avoid perpetual motion and decorative tween chains.
- On touch devices, reserve the default movement/jump corners. Move or recompose bottom actions
- that overlap them, and hide keyboard/gamepad hints when those inputs are not active.
+ that overlap them, and show only the hints for the current `PreferredInput`.
## Common failures
| Symptom | Likely cause | Remedy |
|---|---|---|
| UI disappears or duplicates after respawn | wrong `ResetOnSpawn` policy or stale clone | choose policy; reacquire from `PlayerGui`; clean old bindings |
-| Phone layout clips | desktop offsets/global scale used as layout | add narrow composition, layouts, bounds, and Device Emulator checks |
+| Phone layout clips | desktop offsets/global scale used as layout | add narrow composition, layouts, bounds, and Device Simulator checks |
| Content hidden under topbar/notch | insets ignored or `ScreenInsets = None` | use `CoreUISafeInsets` for interactive UI; inspect intentional bleed |
| Scroll ends early | fixed `CanvasSize` | use `AutomaticCanvasSize` or layout `AbsoluteContentSize` |
| Controller gets stuck | no entry selection or bad neighbor graph | set initial `SelectedObject`; define and test focus edges/modal trap |
diff --git a/skills/other-engines/roblox-ui/references/input-navigation.md b/skills/other-engines/roblox-ui/references/input-navigation.md
index 8b0f076..35b9655 100644
--- a/skills/other-engines/roblox-ui/references/input-navigation.md
+++ b/skills/other-engines/roblox-ui/references/input-navigation.md
@@ -10,7 +10,7 @@ motion. Targets Roblox's rolling platform APIs.
disabled, and busy if an operation can take time. Do not communicate state with color alone.
- Make touch targets comfortably hittable and separated; do not add invisible hit zones that overlap
neighboring controls.
-- Show input prompts that match the active device, but never hide the only explanation of an action
+- Show input prompts that match `PreferredInput`, but never hide the only explanation of an action
during device switching.
## Selection graph
@@ -20,9 +20,12 @@ On screen open, select the most likely safe action—not a destructive action. U
`NextSelectionLeft/Right/Up/Down` where layout geometry is ambiguous. Test every edge and a full
round trip through the graph.
-Set initial selection only after the control is rendered and only for keyboard/gamepad navigation.
-Device emulation can expose keyboard capability while touch controls are active, so prefer the
-active input policy used by the project; do not force a selected object on a touch-first screen.
+Set initial selection only after the control is rendered and only while
+`UserInputService.PreferredInput` is `Gamepad` (or `MicroGamepad`, reserved for TV remotes and
+not yet reported). Capability flags mislead here: `TouchEnabled` is true on touch laptops and a
+phone with a paired gamepad should navigate by focus. Re-check on
+`GetPropertyChangedSignal("PreferredInput")`; do not force a selected object on a touch-first
+screen.
Inspect the default adornment. A custom `SelectionImageObject` must remain a valid visible
`GuiObject` (it can live offscreen as the reusable template) and should match the interface's focus
treatment instead of adding a large glow.
@@ -75,11 +78,12 @@ neighbor graph for moving UI focus itself.
Use Studio's Controller Emulator and also a real controller when available. Verify initial focus,
all directions, activation, back/cancel, tab/shoulder navigation if used, scroll-following selected
items, focus restoration, and mouse-to-gamepad switching. Controller emulation proves mapping and
-navigation, not TV legibility; use Device Emulator/console sizing for that.
+navigation, not TV legibility; use Device Simulator/console sizing for that.
## Primary references
- `https://create.roblox.com/docs/reference/engine/classes/GuiService`
- `https://create.roblox.com/docs/studio/testing-modes`
- `https://create.roblox.com/docs/input/input-action-system`
+- `https://create.roblox.com/docs/input` (PreferredInput)
- `https://create.roblox.com/docs/production/publishing/console-guidelines`
diff --git a/skills/other-engines/roblox-ui/references/responsive-layout.md b/skills/other-engines/roblox-ui/references/responsive-layout.md
index 456d058..4c07b40 100644
--- a/skills/other-engines/roblox-ui/references/responsive-layout.md
+++ b/skills/other-engines/roblox-ui/references/responsive-layout.md
@@ -13,6 +13,8 @@ author's primary monitor. This reference targets Roblox's rolling platform APIs.
layouts instead of manually positioning each child.
4. Use offsets for bounded component dimensions and spacing; use scale for proportional placement
and flexible region size. Inspect `AbsoluteSize`, not device names, for layout breakpoints.
+ In a styled project, a `StyleQuery` (`MinSize`/`MaxSize`/`AspectRatioRange`, or
+ `PreferredInput`) can switch `@`-selector rules at a breakpoint without a resize script.
## Roblox layout primitives
@@ -111,4 +113,5 @@ fixture unchanged.
- `https://create.roblox.com/docs/ui/position-and-size`
- `https://create.roblox.com/docs/ui/size-modifiers`
- `https://create.roblox.com/docs/ui/list-flex-layouts`
+- `https://create.roblox.com/docs/ui/styling`
- `https://create.roblox.com/docs/production/publishing/adaptive-design`