nodes for making responsive UI
  • GDScript 100%
Find a file
Sosasees a48623fb05 remove link to demo on gotm
since gotm shut down forever
	 — sosasees <https://codeberg.org/sosasees>
2024-03-29 12:59:11 +01:00
addons/responsive_ui bump version to 1.1.3 2023-12-08 09:55:44 +01:00
demo add min_scale_factor to DPIScaleControl 2023-12-08 09:47:10 +01:00
media add FullRectControl 2023-12-08 09:18:57 +01:00
.gitattributes first commit 2023-12-08 09:18:37 +01:00
.gitignore first commit 2023-12-08 09:18:37 +01:00
CODE_LICENSE.txt first commit 2023-12-08 09:18:37 +01:00
CONTRIBUTING.md add CONTRIBUTING 2023-12-08 09:18:50 +01:00
export_presets.cfg first commit 2023-12-08 09:18:37 +01:00
icon.svg first commit 2023-12-08 09:18:37 +01:00
icon.svg.import first commit 2023-12-08 09:18:37 +01:00
ICONS_LICENSE.txt first commit 2023-12-08 09:18:37 +01:00
project.godot upgrade to Godot 4.2 2023-12-08 09:47:01 +01:00
README.md remove link to demo on gotm 2024-03-29 12:59:11 +01:00
SCREENSHOTS_LICENSE.txt first commit 2023-12-08 09:18:37 +01:00

responsive UI add-on

for Godot v4.2.stable.official [46dc27791].

an improvement of the original Godot 3 add-on.

to see the add-on in action, run the demo scene under res://demo/main.tscn.

contents

  • LICENSES
  • recommendations
  • add-on node types
    • FullRectControl
    • SafeAreaControl
    • DPIScaleControl
    • ScaleControl
    • MaxSizeControl
    • WidthBreakpoint
    • HeightBreakpoint
    • OrientationBreakpoint
  • how to install this add-on

LICENSES

recommendations

  • only use this add-on in projects with 'disabled' stretch mode, or else it may not work right
  • use signed distance field (SDF) fonts for very clear text at very high scale factors
    • you can enable the project setting GUI -> Theme -> Default Font Multichannel Signed Distance Field if you use the default font
      • if you disable the setting, you will save a bit of storage space because Godot doesn't save unchanged (from the default) project settings

add-on node types

FullRectControl

resizes itself to the 'Full Rect' anchor preset every frame.

ideal as the scene root (or first CanvasLayer child), so that you don't have to press the 'Full Rect' anchor preset button again, every time you change the 'window size' project settings.

see the scene tree of the demo scene (res://demo/main.tscn) for example.

⚠️ since this node overrides its anchors every frame, you can't change its size to something other than the 'Full Rect' anchor preset

SafeAreaControl

resizes itself to the screen safe area if in fullscreen mode, or else to the parent control node.

⚠️ i highly recommend making a Control with the 'Full Rect' anchor preset the scene root — and placing the SafeAreaControl as the child.

because SafeAreaControl uses the parent control for size reference when the window is not in fullscreen mode, making the SafeAreaControl the scene root will have unexpected results.

i also recommend placing only one SafeAreaControl, because placing more may have unexpected results.

see the scene tree of the demo scene (res://demo/main.tscn) for example.

DPIScaleControl

resizes itself based on the screen's DPI. uses the parent control's size as the reference for the original size.

⚠️ i highly recommend placing the DPIScaleControl as the child of the SafeAreaControl — or a Control with the 'Full Rect' anchor preset if the project doesn't use SafeAreaControl.

because DPIScaleControl uses the parent control for size reference, making the DPIScaleControl the scene root will have unexpected results.

see the scene tree of the demo scene (res://demo/main.tscn) for example.

i also recommend placing only one SafeAreaControl, becaue placing more will have unexpected results.

ScaleControl

similar to DPIScaleControl but rescales itself based on a developer-chosen scale_factor, not the screen DPI. really useful for scaling UI based on a 'scale factor' game setting.

⚠️ ScaleControl uses the parent control for size reference, so making it the scene root will have unexpected results.

MaxSizeControl

rescales itself to either the parent control's size or its own max_* values, depending on which are smaller. by turning off restrict_width or restrict_height, this node can also restrict its size on only one of both axis.

⚠️ MaxSizeControl uses its parent control node for size reference, so making it the scene root will have unexpected results.

WidthBreakpoint

is visible if the parent control's width is between min_width and max_width, else it's invisible.

⚠️ WidthBreakpoint uses its parent control node for size reference, so making it the scene root will have unexpected results.

it also overrides any calls to set_visible() with its own logic, so you need to make its parent control invisible instead. see the scene tree of the demo scene (res://demo/main.tscn) for example.

HeightBreakpoint

is visible if the parent control's height is between min_height and max_heigth, else it's invisible.

⚠️ HeightBreakpoint uses its parent control node for size reference, so making it the scene root will have unexpected results.

it also overrides any calls to set_visible() with its own logic, so you need to make its parent control invisible instead. see the scene tree of the demo scene (res://demo/main.tscn) for example.

OrientationBreakpoint

is visible if the parent control's orientation (square / portrait / landscape) is set as allowed, else it's invisible.

⚠️ OrientationBreakpoint uses its parent control node for size reference, so making it the scene root will have unexpected results.

it also overrides any calls to set_visible() with its own logic, so you need to make its parent control invisible instead. see the scene tree of the demo scene (res://demo/main.tscn) for example.

how to install this add-on

※ target project is the Godot project that should have this add-on installed

  1. copy the res://addons/responsive_ui/ folder from this project into the same path (res://addons/responsive_ui/) in the target project
  2. open the target project in Godot
  3. open the Project → Project Settings… menu
  4. go to the Plugins tab
  5. enable responsive UI plugin