How do I make my label in Unity size to fit its text? - unity3d

I am working on the credits for my mobile game and I have a license attribution thing at the end that is relatively long. On normal phone screen sizes it fits properly, but on notched phones, a big chunk of the end gets cut off and on tablets, there is a lot of empty space at the top and bottom. I had both the label and the content panel of the ScrollView for the credits set to the anchor preset which is anchored to the top of the parent but stretches horizontally and I tried changing it so that they stretch vertically too and that did nothing. I also tried moving the label's anchors to its own corners (but didn't do that with the content panel's anchors because that's not possible), but that also did nothing. I asked this on Unity Answers earlier this week and they haven't been very helpful. How do I make the text not get cut off or have a lot of extra space?

I eventually just clicked "Best Fit" on the text and now it fits properly. I was worried that it would look bad if it was a different size on different screens, but it doesn't seem to be a huge problem.

Related

Unity3D is sizing icons differently

Bellow is a section of my games UI made in Unity3D. I was adding the icon on the left side when I realized that it was much larger than the icon in the middle so I went to give them a similar size. According to the Rect Transform of these objects the icon in the center of the screen is larger than the one on the left which again according to the Rect Transform is the smallest icon on the screen.
Does anyone know of why this might be? I don't quite understand Unity's units of measure. These icons are nested in many game objects with Layout Groups, Content Size Fitters, and Layout Elements. So I am not exactly sure what is retentive to these icons but I will show their parents and grand parents here.
If There is anything else I can you would need to know I can post more info.
You don't show the scale of the rect transforms so I assume they are the same.
Layout groups and content size fitters will (if you allow them to) change the size of the GameObject to make it fit a certain space, that is what they are for! This will then override the size that you have manually given to the GameObjects.

How to make Flutter responsive for Web? Not working: MediaQuerys, fixed pixels, and BoxConstraints, etc

I am coding a website with Flutter. My layout uses "blocks" of vertical content laid within a SingleChildScrollView. They look like rectangles of content (with images, text, buttons, etc in them), taking up the whole screen horizontally, and the whole screen vertically.
Currently, whenever I move the screen size around (drag the web window to be different sizes) the website breaks. If I move it to be really small horizontally, I cannot fit in the content I need, if I move it to be small vertically I get overflow errors (and vice versa). This is because I am using MediaQuery.of(context).size.height/width to layout my website.
My rectangular blocks of "content" all have their same respective parent: Container(width: MediaQuery.of(context).size.width, height: MediaQuery.of(context).size.height) so they completely adjust everytime I move the window. Is there a better way to implement responsive web? Would it be better to just specify (for example) 620 pixels height for the Container and double.infinity for the width? And then somehow make everything fit inside not overflow/look weird? Also, when I drag the bottom of the web window nothing expands/grows properly because at that same time all my "content blocks" are all resizing their height because I am technically resizing the screen.
Finally, I've tried using BoxConstraints's minHeight, maxHeight, minWidth, and maxWidth, yet they don't seem to work and still produce the yellow/black overflow lines when testing in a webview. Huh?
Also, how would I get a bottom scrollbar to appear horizontally once my webview window is fully dragged close horizontally and half my content is cut off, but I still would like to see it. Would this be necessary? Or would another solution not need this? I'm not sure...
How are other people working around this and achieving this? I feel like I am doing this completely wrong. It shouldn't be this difficult.
(Also, using LayoutBuilder I have 2 additional builds for mobile/tablet when the screen width reaches less than 1100px)

Why there is a difference in the text size when show it in one Text ui and another Text ui with the same settings?

The post is a bit long but I tried to explain everything that is connected to the issue.
This screenshot is of the parent ui texts canvas.
This is a screenshot of the description ui text the text in the game looks very big the fonts are very big and stretched.
This is a screenshot of the scene text Image settings :
And the scene ui text settings :
This is a screenshot of the scene ui text when running the game from the exe build file :
And last the description ui text in game when running the build exe file :
How can I make some ui text that will be display the text the same in all the cases something that will be readable nice not too small and not too big ?
In the scene text the text is smaller because I wanted the text to be a bit under the player mouth. In the description text is a bit bigger but then everything get messed.
I think I want the text to be shown like in the scene ui text in all the places. I think the size is fine. but not sure how to do it.
There's a couple of things here that should get your text working nicely across the board.
Firstly, at your root Canvas object, you'll usually have a Canvas Scaler there. The default of "Constant Pixel Size" is often exactly what you don't want. I normally have it set to "Scale With Screen Size", and then set the resolution to 1920x1080. I do that because 1920x1080 (16:9) is the standard Full HD screen size, so you can bet that most of your screen layout is going to look the same across most displays.
The second suggestion would be to use TextMeshPro. If you haven't already got it installed through your Package Manager, then you can find it there. Here's the docs for that. It's FAR superior to the standard Text element and you'll notice less issues trying to get your text looking correct. It's usually just a matter of adding the TMPro_Text UI component to the same object your Text component was originally on (removing the original Text component of course).
I would also leave all scaling for all of your UI items set to (1, 1, 1) where you can and let and scaling be done by the Canvas Scaler. The text elements can certainly be left at (1, 1, 1) and just change the font size.
Once you get these three things sorted, your text should be the same across all of your pages, and devices.
This due to Scaling Rect Transform Component
to solve this don't scale up or scale down UI Elements {Image ,Text, ... just keep Scale 1,1,1 }
First I recommend You to see This to understand this Component
https://www.youtube.com/watch?v=FeheZqu85WI&t=6s
Now to Solve your problem
Set Scale of Description Image (1,1,1)
Set Scale of Description Text (1,1,1)
Do 1,2 with Scene Image, Scene Text
Change Width , Height of{Description Text, Scene Text} with small values 900*400

Unity grid system woes (How to make grid that auto-collapses to column in portrait mode

My problem is very difficult to describe, so hopefully (with the pictures I provide) someone can help me figure this out. If you are confident you can fix it, I'm willing to pay if I have to. I need this fixed.
I cannot for the life of me figure out how to work with the Unity canvas/layout groups. I have a series of canvases that only show one at a time (think of them as screens). Inside each canvas are components (the first one is a graph and timer, and then a data panel and some buttons.
Here is an image of what I'd like each of the panels to look like (only one of these will be open at a time):
Essentially, I just want each sub-canvas (the dark gray boxes) to inhabit ~50% x 50% of the screen, and when the orientation is horizontal/vertical, tile them accordingly.
Each Child panel (the dark gray) only needs to change. The children inside of the panel can stay and scale relative to the parent canvas.
I have tried EVERYTHING, dug through the documentation, and have run out of options.
Have you tried adding a Layout Element to all of those gray panels with a Flexible Width or Height setting? The screenshot below shows how to have two panels that are side by side, both occupying half the width of their container. (Both have a Flexible Width setting of 1.)
The two Panels are children of the Canvas that has a Horizontal Layout group like this:

Unity3D issue with font size near text height

I'm facing an issue where a text in the Unity UI does show on my PC, but doesn't show on my smartphone (and the phones of thousands of players actually). The disappearing basically comes from the text-component setting to truncate vertical overflow, but there shouldn't be any vertical overflow in the first place.
So when I have my font size at 24 and the text-component height at 30, it is not a problem on either platform, but once the font size gets "near enough" to the text-component height (but is still lower than it), so in this example let's say 28, then it'll still appear on PC, but not on my phone.
I'm actually not sure, if this has something to do with the phones OS (Android) itself, or with the DPI and the scaling of the canvas with the canvas scaler.
Anyways this is really annoying, so is there a neat way to fix it? I btw. don't want to set all text-components to vertical overflow, because that's not what I intent to do in multiple cases.
The solution is actually to set your Horizontal and Vertical Overflow to Overflow instead of Truncate.
This is the safest method that will force all the text from your Text component to render but I don't know why you don't want to use it.
You still have other solution but they are not better than what I said above. Although, they should work.
1.If your Text is a mult-line text, decrease the Line Spacing values below 1 and that will make more of your Text show.
2.If it is a single-line text, then Enable the Best Fit check box then decrease the Min Size and increase the Max Size until you get what you want.