Hi people I need some help regarding my UI, I went through all basic stuff such as content size fitter and Horizontal Group Layouts. In my editor everything worked fine, looks good no problem. However when i build the game, the dialogue box scaling is off. Every other UI scaling worked just fine. I just couldn’t figure out what happened, any suggestions would help!
The image above worked fine and correct in Editor.
Here is the Build version.
****Changing my Canvas Scaler from 1920x1080 to 800x600, then re-arranged everything. Solves the difference in front size between Editor and Build version. Fixes for now, still not the true solution to why with 1080p resolution couldn’t manage Build version’s Text scaling properly.
looks like an extra line is added in the build. I don’t think I saw this so far, might be a bug with that version of unity, though LTS makes this less probable.
are you using textmeshpro or the legacy text component?
the way I was doing it is add a layout group+csf on the box and that’d automatically resize the box according to its children (the text component forwards its desired size to the parent). is that how you’ve done it?
what bug I was getting sometimes is the text wrapping unexpectedly on 2 lines instead of 1, but I’d also see parts of the text, while here it’s just an empty line. I remember tweaking the wrapping setting and fixing it, but not sure if it’s the same issue here. just guessing here, but maybe adding some padding could also fix it
I have been fiddling around for a while, things are getting better but still having unexplained scaling issues. I am using textmeshpro and had the exact same setup regardings the Horizontal layout group + csf on the parent object as you said. Changing the vertical fit option to min size in CSF kinda makes the white box conform with the text, so I don’t think an unexpected line is added.
Atleast the text arrangement to box part is fixed. Now trying to fix the scaling bit, still differs between Build and Editor, no text auto scaling is used.
Here is how to understand all your scaling issues:
Here are the official docs on how to make your UI handle various resolutions and aspect ratios cleanly:
Here are some notes on UI Anchoring, Scaling, CanvasScaler, etc:
Usually you need to choose a suitable ScaleMode and MatchMode in the Canvas Scaler and stick with it 100%. Generally if you change those settings you will often need to redo your UI entirely.
I also use this CanvasScalerOrientationDriver utility to make sharing UI for Landscape / Portrait easier. Read what it does carefully.
Thanks for the reply, but it is quite difficult for me to pinpoint the problem since, all my other UI looked correct and scales correctly in both Editor and Build version.
Except for this Dialogue UI, which worked and looked fine in Editor. But scales wrong in Build, oh and FYI the only difference between this Dialogue UI and all other UI with Text in the game is, this Dialogue UI is the only dynamically instantiated and destroyed UI prefab (with Text) in the game, this prefab is instantiated as a children to my Canvas which has all basic settings of Canvas Scaler and things like that, not sure if this bit messes itself up? But if that’s the case it should’ve been easily spotted in Editor, therefore I’m stuck in a sticky situation, not able to check what went wrong and cannot easily read debugs.
My Unity version is quite dated at 2019.4.40f1, not sure if its related to this.
Imagine how hard it is for someone here who can’t see your screen!
If you read the links I provided above, it explains how to use the resolution settings in the Game window to rapidly test (in the editor) a representative range of aspect ratios and/or pixel counts until you are confident you have anchored everything correctly.
That is a very sticky situation, probably the first thing you should correct. Learn how to iterate and test and read what is happening. If you are unable to do this I guarantee nobody here can do it for you in this little tiny text box.