Skip to content
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

Stretching with anchors does not take into account the scale of the nodes. #56746

Closed
4CoDev opened this issue Jan 13, 2022 · 9 comments
Closed

Comments

@4CoDev
Copy link

4CoDev commented Jan 13, 2022

Godot version

3.4.2.stable.mono

System information

Windows 11, GLES3, RTX 3080 Ti

Issue description

I made a microscopic pixel interface in my game with the ability to scale (x1, x2, x3, etc.) as in minecraft. When using wide anchors stretching does not take into account the scale of the nodes, so they are out of the edge of the window.

x1
image

x2
image

Steps to reproduce

  1. Create Panel node
  2. Set Left Wide anchor
  3. Set Scale for node

Minimal reproduction project

AnchorAndScale.zip

@Calinou
Copy link
Member

Calinou commented Jan 13, 2022

Related to #52383.

I made a microscopic pixel interface in my game with the ability to scale (x1, x2, x3, etc.) as in minecraft.

With Godot's support for multiple resolutions and the 2D scale factor property, you do not need to do this. Control scaling should only be used for animation purposes or prototyping, not for anything else.

@4CoDev
Copy link
Author

4CoDev commented Jan 14, 2022

With Godot's support for multiple resolutions and the 2D scale factor property, you do not need to do this. Control scaling should only be used for animation purposes or prototyping, not for anything else.

Oh, that sounds like just what I needed, thank you! But I still think this behavior from the scale looks wrong.

@Maran23
Copy link
Contributor

Maran23 commented Jan 14, 2022

Related to #52383.

I made a microscopic pixel interface in my game with the ability to scale (x1, x2, x3, etc.) as in minecraft.

With Godot's support for multiple resolutions and the 2D scale factor property, you do not need to do this. Control scaling should only be used for animation purposes or prototyping, not for anything else.

Hm, what I don't understand then:
When I design a user interface which looks good on Desktop 1920x1080, it typically looks too tiny on a mobile with something similar like 1920x1080 since the screen is much smaller and the pixel dpi much higher.
What is the best way to have a proper setup for all platforms/screens?

I understand that scale might not be the best bet here, but when I tried 2d stretching with a lower base resolution instead things doesn't look so crisp on desktop.

@Calinou
Copy link
Member

Calinou commented Jan 14, 2022

What is the best way to have a proper setup for all platforms/screens?

Use the new 2D scale factor property to increase the size of UI on mobile platforms, regardless of the actual screen resolution. You can do this automatically on mobile platforms by overriding the Stretch Shrink project setting with the .mobile feature tag.

@Maran23
Copy link
Contributor

Maran23 commented Jan 18, 2022

What is the best way to have a proper setup for all platforms/screens?

Use the new 2D scale factor property to increase the size of UI on mobile platforms, regardless of the actual screen resolution. You can do this automatically on mobile platforms by overriding the Stretch Shrink project setting with the .mobile feature tag.

Big thanks, that worked very well!
I was not aware I could overwrite a property for e.g. mobile, although it makes a lot of sense. Also shrink is not the best name here but I think this is fixed on 4.0 if I recall correctly.

I have read Multiple Resolutions multiple times but didn't found the answer there, maybe it makes sense to document it there as well and link it to the Feature Tag.

@azagaya
Copy link
Contributor

azagaya commented Mar 3, 2023

Is there a way to change the shrink by code (besides set_screen_stretch())? because not all mobile devices have the same screensize and dpi, so different scaling may be needed for different devices.

@Calinou
Copy link
Member

Calinou commented Apr 28, 2023

Is there a way to change the shrink by code (besides set_screen_stretch())? because not all mobile devices have the same screensize and dpi, so different scaling may be needed for different devices.

Yes, see godotengine/godot-docs#7136. This can be done in 3.x too by changing shrink, which accepts floating-point values since 3.4.

The Multiple Resolutions demo project showcases this for both 4.x and 3.x (Window Scale Factor in the demo).

@cidwel
Copy link

cidwel commented Dec 10, 2023

I have a different usecase where I just want to scale some element in my UI.

I think this ticket is still relevant. anchor positioning should affect scale factor
image

I even found some weird effect where I reset the "Transform size X" and it just anchored correctly. I haven't managed to replicate it again

@Calinou
Copy link
Member

Calinou commented Dec 16, 2023

Thanks for the report! Consolidating in #19068.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants