'In Unity UIElements, what is the equivalent to 'Scale with ScreenSize' of UGUI Canvas Scaler?
If I want to make my UI gameobjects stay the same size and position on all devices when I use UGUI in Unity3D, I simply set UI Scale Mode to Scale with Screen Size in Canvas Scaler. But now Unity3D switches to UIElements system, not only for Editor, but also for run-time in-game UI, how can I do the same thing?
Also, how can we still simply maintain the aspect ratio of the game screen at the cost of losing screen space, like the Auto Letterbox (black bars) plugin does for us?
(all for run-time in-game UI)
If it is too early to know all that exactly, could anyone please let me know if these approaches would still be possible? Or those solutions are simply not possible due to the nature of 'web-style' development mechanism that the UIElements system will be based on?
Thank you very much, and sorry for any obsecure expreesion I may have put here.
Solution 1:[1]
Scaling can now be set in Unity's UI Panel Settings asset.
When adding a UI Document to a GameObject, this asset can be specified in the Panel Settings
field as seen in the editor below:
When configuring the Panel Settings, you can choose to use a scaling mode, such as in the image below. I am using a reference size in pixels (iPhone X resolution)
The Match Width Or Height
scaling mode should scale according to what you expect, just like UGui did for device scaling before UI Toolkit was introduced.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Felipe |