- Home /
UI Toolkit and Builder scaling issues when building for Android
Hi, I'm having some trouble with scaling elements in UI Toolkit when building for android. If I set a size of an element in pixels then the elements appear too big once I've built the game onto my device.
I'm using Unity 2020.3.11f1 and a Samsung Galaxy S20+ with both the UI Builder and UI Toolkit packages in version 1.0.0-preview.14.
My steps are, in order, as follows;
Create new 2D project using 2020.3.11f1 (LTS).
Switch build platform to Android, keeping default settings.
Add the UI Toolkit and UI Builder packages.
Create a new UIDocument Gameobject.
Change the Remote Device settings to use any android device, PNG compression and normal resolution, and run the latest version of Unity remote on my device.
Open the UI Builder window, toggle 'Match Game View' to match my remote device and change the Game View's Aspect Ratio to 'Remote'.
Add a new Label in the UI Builder, align the text to center and increase the font size to 50px.
Save the file as Test.uxml and apply it to the UIDocument Gameobject.
When I run the game this is what I get...
When I build the game, this I what I get instead...
Everything gets scaled up and I'm not sure why, this doesn't just happen to text, but seemingly any element that is assigned a size in pixels rather than percentage.
Any idea what the issue might be?
Answer by unity_IpxdANggCs1roQ · Jun 10, 2021 at 10:00 AM
In the PanelSettings asset of your UIDocument, set "Scale Mode" to "Constant Pixel Size".
Your answer
Follow this Question
Related Questions
InputField caret too big in world space canvas 0 Answers
UIToolkit UIProgressBar methods changed 0 Answers
In WebGL, is it possible to make UI Coordinate scale with CSS style? 1 Answer
UI Toolkit: Is it possible to modify USS custom properties (variables) with C#? 0 Answers
How could I make a “discovery” UI? 1 Answer