- Home /
New UI: Text scale/drawing problem
Hi!
In new UI small texts(texts with a small font size) looks terrible. I do not know what the reason of that but I was adviced to increase font size to some big number like 50 for example and then scale it down to the size I need. So for static unscalable text it is very good solution. However my text is the child of the parent and the parent could be scaled so the text should also be scaled. The problem is that text have some scale like 0.05 and when the entire parent increase his scale the scale of Text doesnt changed at all.
How could that problem be solved ?
Update: I found some strange behaviour.. I create a sprite and put there some text it will be differnce between the case when we start our application with "MAXIMIZE On Play" and without it for the text scaling..
Here is a screen:
So on the left "Maximize on Play" is off
on the right "Maximize on Play" is on(scaled to the size of the screen on the left for comparison)
Also you could revert to back from on mode to another during runtime and when Maximize option is off the text will be scaled correct!
Thank you in advance.
P.S. Test project is here.
I have seen something similar in Unity 4.6.3f1. I posted it as a question here: http://answers.unity3d.com/questions/937207/rich-text-font-size-behavior.html
Answer by Phuzz · Dec 01, 2014 at 07:52 PM
Hello,
Have you tried the "Best Fit" option? it should have the text scaled properly to its parent, but I heard it could have a small impact on performance.
Hi!
Yes, I have. You could represent this issue:
Create some sprite
Create Text as a child of that sprite and put it in some part of that sprite
$$anonymous$$ake Text Font size: 50 and scale it down to the size you need
You may also create a script that will scale the parent object. Simple example:
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class Test : $$anonymous$$onoBehaviour { private RectTransform rectTransform; private Vector3 startPosition; // Use this for initialization void Start () { Text txt = GetComponent(); rectTransform = GetComponent();
} // Update is called once per frame void Update () { if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.P)) { Debug.Break(); } } public void OnCardDown() { rectTransform.localScale = new Vector3(7, 7, 7); startPosition = rectTransform.localPosition; rectTransform.position = new Vector3(Screen.width * 0.5f, Screen.height*0.5f, 0f); } public void OnCardUp() { rectTransform.localScale = new Vector3(1,1,1); rectTransform.localPosition = startPosition; } }