Responsive UI
Use when handling multiple resolutions, stretch modes, aspect ratios, DPI scaling, and...
Install
npx skills add jame581/GodotPrompter --skill responsive-ui -g -a claude-code -y- Repository
- jame581/GodotPrompter914
- Category
- Engineering
- Updated
- 3d ago
- License
- MIT
- Context cost
- Mediumabout 2,426 tokens
- Runs scripts
- No, instructions only
What it does
Use when handling multiple resolutions, stretch modes, aspect ratios, DPI scaling, and mobile/desktop adaptation
Responsive UI in Godot 4.3+
All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.
Related skills: godot-ui for Control node layout and themes, export-pipeline for platform-specific export settings, godot-project-setup for initial project resolution settings, input-handling for touch vs desktop input adaptation, localization for layout adjustments per locale, mobile-development for safe-area and notch handling.
1. Project Settings for Resolution
Configure base resolution and stretch behaviour in Project > Project Settings > Display > Window.
Key settings and their keys in the [display] section of project.godot:
| Setting | project.godot key | Recommended value |
|---|---|---|
| Viewport width | window/size/viewport_width | 1920 (or your base design width) |
| Viewport height | window/size/viewport_height | 1080 (or your base design height) |
| Stretch mode | window/stretch/mode | canvas_items (most games) |
| Stretch aspect | window/stretch/aspect | expand (fill screen) or keep (letterbox) |
| Scale factor | window/stretch/scale | 1 |
| Scale mode | window/stretch/scale_mode | fractional; integer for pixel art |
Godot 4.7+: Projects newly created in Godot 4.7 already default
display/window/stretch/modetocanvas_itemsanddisplay/window/stretch/aspecttoexpand(previouslydisabled/keep), the recommendations above are now the out-of-the-box values. Projects created on older versions are unchanged (the property default is stilldisabled), so set both explicitly when upgrading. See the 4.7 migration guide.
The engine reads these settings once at startup; changing them with ProjectSettings.set_setting() later has no effect. At runtime, set the matching Window properties instead:
GDScript:
