-
-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a built-in UI scaling solution #8404
Comments
This is already available in 4.2.beta: godotengine/godot#75784
This is also available since Godot 3.4: https://docs.godotengine.org/en/stable/tutorials/rendering/multiple_resolutions.html#stretch-scale If you only want the UI to scale and don't want the rest of 2D rendering to scale, multiply Camera2D zoom by the scale factor in |
stretch-scale is different from what i'm saying. When doing ui, scaling at the transform level is a very bad idea. every control, from corner radius to font sizes need to be scale aware. If proper scaling is implemented for the game engine, it will transform it's core ui capabilities for high end usage. |
This is a different and older approach to hiDPI scaling, which should really be phased out as it's inconsistent (not all controls benefit from it the same way) and can't be changed while the project is running. It's also editor-only anyway. If you're thinking of changing the 2D scale factor to adapt to hiDPI displays automatically, #7968 is a better approach.
The 2D scale factor automatically takes care of font sizes, styleboxes, etc. You don't need to do anything special for things to scale correctly – it just works. The downside is that icons will be blurry at higher-than-default window sizes, but this can be alleviated by using a high default window size and using a lower window size override in the project settings.
This is an unrelated issue: godotengine/godot#61301 |
with hidpi are the controls capable of knowing their real rect_size (after scaling) if they want to perform custom drawing? |
Yes, custom drawing coordinates are adjusted automatically. If you need to perform custom drawing that does not scale with resolution for some reason, divide the coordinates by the scale factor in the script.
They'll be rendered at a higher resolution but with the correct size relative to the window size.
Yes, it's platform-independent. |
So basically if you set your design size to 4k, on a 1080p monitor you will be using 4 times the rendering power? and on lower resolutions that multiplier will only go up. Is this correct? I'm not experienced with hidpi so i'm asking a question. |
No, rendering is scaled down if using the |
Describe the project you are working on
A godot project with a responsive UI.
Describe the problem or limitation you are having in your project
2D scaling is not perfect. i need pixel sharpness. and that can only be achieved with scaling turned off. but that will result in me scripting the entire stylebox and fonts and controls to make my ui responsive.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
float Viewport::ui_scale property.
Viewport::ui_scaling_mode property with {disabled, enabled, inherit}
new notification of "VIEWPORT_UI_SCALE_CHANGED"
new viewport signal of "ui_scale_changed"
all the controls will need to be readjusted to use the ui_scale multiplier if desired (with the options of disabled, enabled and inherit)
controls should use the multiplier for their styleboxes and font size as well.
fit_child_in_rect should also use the value.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
the user can create a script to decide the ui_scale.
then that ui will be used to adjust everything that wants the auto scaling. the ui will stay pixel perfect.
If this enhancement will not be used often, can it be worked around with a few lines of script?
no. i usually end up setting up a whole system just to start developing ui for a project.
Is there a reason why this should be core and not an add-on in the asset library?
it's an essential requirement. 2D scaling is not the solution. this is. while it's harder to implement it is the real solution.
In mobile applications languages like kotlin provide things like "dp" to solve this problem.
The text was updated successfully, but these errors were encountered: