TextMeshPro Text Object is not visible in unity gameView

Created a script that adds a textMeshPro text in a gameObject that is child of a canvas. But the text is not visible in the gameView playmode but it is visible on scene mode. The text size is made big and the position is Oth point.

enter image description here

Heres the code to make the textmesh object:

public GameObject g; // Use this for initialization void Start () { TextMeshPro mText = g.AddComponent<TextMeshPro>(); mText.autoSizeTextContainer = true; mText.text = "Hello there"; // Set various font settings. mText.fontSize = 748; mText.alignment = TextAlignmentOptions.Center; } 

How can I make this visible to the camera? and Why its not rendering?

5

1 Answer

You can place a TextMeshPro GameObject in either world space (Create > 3D Object > TextMeshPro - Text) or UI space (Create > UI > TextMeshPro - Text). As a 3D Object it has a MeshRenderer so it is "in the world" and with the UI version it is "in the screen" using a Canvas.

FYI, your code worked for me, but I had to the using TMPro; directive at the top.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like