Add TextMeshPro component to gameobject

35 views Asked by At

When i add TextMeshPro component to gameobject my gameobject and mesh filter disappear. What is the problem?

private TextMeshPro m_text;

    void Awake()
    {
        m_text = gameObject.GetComponent<TextMeshPro>() ? gameObject.GetComponent<TextMeshPro>() : gameObject.AddComponent<TextMeshPro>();

        m_text.font = Resources.Load<TMP_FontAsset>("Fonts & Materials/LiberationSans SDF");

        m_text.fontSharedMaterial = Resources.Load<Material>("Fonts & Materials/LiberationSans SDF - Drop Shadow");

        m_text.fontSize = 4;

        m_text.text = "Player name";

        m_text.transform.position = gameObject.transform.position;

        m_text.rectTransform.sizeDelta = new Vector2(3f, 3f);
    }

    void Update()
    {
        m_text.transform.Rotate(Camera.main.transform.eulerAngles - m_text.transform.eulerAngles);
    }

Mesh filter and material was changed to TMP

0

There are 0 answers