Canvas Scaler is not applied to the dynamically added canvas text
Hallo everyone. To scale the canvas text and images for different resolutions I am using canvas scaler. But my Text object which I instantinated in the runtime and added to the canvas is not scaled. Does anybody know what is the problem?
Answer by Ponytech · Oct 04, 2017 at 01:28 PM
I had the same problem. I solved it by setting worldPositionStays to false as the second parameter to SetParent.
newText.transform.SetParent(canvas.transform, false);
THAN$$anonymous$$ YOU! I just spent the last 4 hours trying to figure this out, this worked perfectly. THAN$$anonymous$$ YOU!
Answer by CybernetHacker14 · Oct 05, 2017 at 08:54 AM
If you consider using Unity UI components, there is an option for Text UI called as 'Best Fit', which will convert the text to suitable size, and filling up the necessary text space. Try it out.
Your answer
Follow this Question
Related Questions
Display rigidbody speed to a world space canvas text 2 Answers
Meaning of Dotted Rectangle Widget in GUI System 0 Answers
Locate _MainTex from a public shader and assign to instantiated prefab for GUI 1 Answer
Is there an order in the "Layers" tab? 0 Answers
How to add Background Images for Vertical GUILayouts in Unity3d Custom Editor Window 0 Answers