I’m using a custom font in my game and have noticed that recently some of the Text objects are no longer rendering. If I change the font back to Arial then they render. I can also get it to render again if I change the custom font from dynamic to unicode, but if I increase the size of the font (from 16, as it’s blurry) to a higher number, it starts to disappear again.
I would put it down to an issue with the font atlas if none of the text was rendering, but most of it is, it’s just a few objects that aren’t.
It’s important that I’m able to use the same font everywhere for consistency.
Has anyone experienced similar issues and know of a solution without compromising the sharp text rendering?
The version of Unity I’m using is 4.6.2f1.
EDIT: It must be an editor bug - it works when maximised on play, and it appears to be working on mobile ok.
That sounds like your text is bigger than the width and height of the game object and you have the Text overflow set to hide things that don’t fit.
You have different options:
Set the overflow to “Overflow” in both directions. This will make ANY text always visible, the bad thing about it is that the text might be bigger than the area you defined for the UI element, overlapping other elements.
Increase the size of the area using the Rect Transform until the text is visible. You control the size of the object, but you have to do it every time you change a text.
Turn on the “Best fit” option on the Text component. With this method you get a constant size for you object and the text will always fit, but Unity will change the font size automatically, which may be bad for some cases.
Add a Content Size Fitter component and set horizontal to “Preferred size”. This way the text will always be inside the area with the font size you selected, but the area will get bigger or smaller depending on length of the text inside.
Edit: It probably works Maximizing or in a build because of how Canvas Scaler works, I guess for some resolutions the font size might be a little bigger.
@Skully
Check the “Best Fit” option in the Text section of the Inspector. It will give you two extra options of Min and Max size. Set the max size to your text size and you can set min to either 0 or the same value as the max.
This solved the issue for me. Hope this helps you.
I had a similar issue, and the culprit was the corruption of the default UI material (which is the one used when you don’t assign a specific one to your UI element). This can happen if you have a script accessing the .sharedMaterial property.