Unity3D issue with font size near text height - unity3d

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.

Related

How to resize an NSImageView in an NSStackView?

I'm working on a project where I want the following in an NSTableViewCell:
Image
Text
Subtitle text
The NSTableView is in a window which the user can expand or contract. When the window expands and contracts, the text wraps as needed.
That much is working.
When it comes to the image view, I can't get the thing to resize at all. I don't understand how the text automatically wraps, but images don't automatically scale. I've been working on iOS so long that I might have missed something in how stack views differ between iOS and macOS, but I never had this problem in iOS.
I don't have much code because the text wraps properly without any code at all, so instead I posted a minimal project showing the problem on Github:
NSImageTableViewTest
Some things I tried:
I have to set the width/height of the image view, or the text won't wrap. It seems to me that the reason why is that if I keep the image view unbound, the table view starts at the width of the image.
I tried setting the leading and bottom constraints of the image view to no avail.
I tried setting the constraints of the NSStackView, but that doesn't help constrain the frame of the image view.
Question: do I have to change the frame of the image view in code? I did try that, to no avail.
At this point, I'm stumped and I'm sure the fix is something easy that I overlooked.
Thanks.
The image view doesn't shrink because the default Content Compression Resistance Priority is too high. Set the Content Compression Resistance Priority to (a bit lower than) "Low (250)".

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

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.

Shrink text horizontally if width exceeds container size with Unity2D

So, I am trying to use Unity2D to create a TCG/CCG video game, and I seem to have hit a light bump: I cannot seem to efficiently resize horizontally text that ends up being larger than its container. (Example: Text has a width of 200, I want to fit it in 170). I mean, Unity did have a "fixing" with the option "Best Fit", but it didn't quite work as well as it should have, instead changing the font size to better fit it (Which is not the expected result.)
Now, I know that I could just find the width of a text, check if it overflows, and then apply simple math to scale it on the width side. That's something I'm currently trying to put into the code: But! I am looking for something I would have overlooked within Unity. Something that would do it faster, without me having to hard code it.
Now, what I have tried thus far (to avoid repeat of those offers):
Best Fit (actually changed the font size, which didn't fit my needs)
Both "Horizontal Overflow" settings
Content Size Fitter (Additionally, I seem to not be able to GetComponent<> that one.)
If you know of any trick I should probably know, feel free to let me know: It'd help my coding a lot.
Thanks in advance!
TextMesh Pro is a free Unity Asset that has support for Auto-Sizing and fitting text in specified areas, both as text floating in 3D Space, and as UI Text. Upon creation of a TextMesh Pro object, there is a setting called "Auto-Size" which is what you're looking for.
Details on how Auto-Size works can be found here.

Unity: text is clear in editor but blurry in game

I've read that Unity has problems rendering clear text and I've tried out several different fixes: setting a large font size on the imported font and changing the character setting to unicode, making the text size large and then scaling it down, setting filter mode to point when it comes to pixel fonts... All these methods seem to work from the editor (as in, the text appears crisp), but in the game the text is still blurry:
vs.
(The screenshot is using free aspect - the text looks better, but still somewhat blurry, when the game view resolution matches the reference resolution.)
Currently, the imported font (not pixel) is set to a size of 180; rendering to smooth; character to unicode. The text isn't scaled right now and is at a size of 50. The canvas is set to scale with screen size, and the reference resolution is 2560x1440 (a Samsung S7). It should also be noted that at a different resolution, the box around the text (which is an image) also gets blurry, which makes me think it's a problem with the canvas scaling.
What am I missing?
Turns out all I had to do was uncheck Low Resolution Aspect Ratios in the game view... The text is still slightly blurry, but likely that's typical of Unity. To counter that, I just decided to use a pixel font (using the fix explained in this video).
I use scaling down as a workaround.
For me, it was using Unity-Remote. After building the app directly I didn't see the blur anymore.
I had the same problem, the best solution to the blurry text problem in Unity is as follows:
Select the text item from the scene.
Go to Font and see where your font is located in your project folder
Go to your font in your project
Change the font size from 16 to 100-300
change "Character" to "Unicode"
Press Apply

How to avoid scrolling as well as acquire the whole frame of UITextView in iPhone?

I have a fixed size UITextView whose text keeps varying. I want to display the text in a fashion that user dont need to scroll and still he can see the whole text. Also if the text is very short then, it will acquire the whole TextView to make sure user dont see an empty space.When I say the text keeps varying means the length keeps varying.
So as the size is fix and text is varying I know I need to change the size of font for the text. But how to find such an accurate font which will acquire the whole UITextView and avoid scrolling.
I tried using sizeWithFont but it doesnt work. Any kind of help specially with code is appreciated.
Thanks.
Have you thought of using UILabels, with its automatic font sizing to make the text fit a certain rect?