title: Why I don't see any text on the text component when running the game?
body: <p>I want to see the "Hello World" text. But there is nothing.</p>
  
  <p>Either if using <code>3D Object &gt; 3D Text</code>
  Or <code>UI &gt; Text</code>
  Or <code>UI &gt; Text - TextMeshPro</code></p>
  
  <p>No matter what text component I'm using since there is no mesh renderer attached to it I'm getting exception so I'm adding to the Text component first a mesh renderer.</p>
  
  <p>But then I'm getting exception say there is no TextMesh component attached to the new created texts so I'm changing this line :</p>
  
  <pre><code>var textmesh = newText.GetComponent&lt;TextMesh&gt;();
  </code></pre>
  
  <p>To</p>
  
  <pre><code>var textmesh = newText.GetComponent&lt;Text&gt;();
  </code></pre>
  
  <p>But still it's not working getting exception say textmesh is null.</p>
  
  <p>So I changed the text component to UI > Text
  Added to the text a MeshRenderer and now not getting exceptions/errors :</p>
  
  <p><a href="https://i.stack.imgur.com/eCUtU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eCUtU.jpg" alt="Text"></a></p>
  
  <p>And</p>
  
  <p><a href="https://i.stack.imgur.com/owzJr.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/owzJr.jpg" alt="Text"></a></p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  
  public class AddTextToObject : MonoBehaviour
  {
      public UnityEngine.GameObject[] objectsToNumber;
      public UnityEngine.GameObject text;
      public float yPadding;
      public bool rotateNumbers = false;
      public float rotationSpeed = 10f;
      public bool textChild = false;
      public bool textAbove = false;
      public bool textInFront = false;
      public bool textOnFaces = false;
  
      private List&lt;GameObject&gt; newTexts = new List&lt;GameObject&gt;();
      private MeshRenderer[] renderer;
      private Vector3 newPos;
  
      private void Start()
      {
          renderer = new MeshRenderer[objectsToNumber.Length];
  
          for (int i = 0; i &lt; objectsToNumber.Length; i++)
          {
              GameObject newText = Instantiate(text);
              renderer[i] = newText.GetComponent&lt;MeshRenderer&gt;();
  
              if (textAbove == true)
              {
                  newPos = new Vector3
                  (
                   objectsToNumber[i].transform.position.x,
                   ((objectsToNumber[i].transform.position.y + renderer[i].bounds.extents.y) + yPadding),
                     objectsToNumber[i].transform.position.z
                   );
              }
  
              if (textInFront == true)
              {
                  newPos = new Vector3
                  (
                   ((objectsToNumber[i].transform.position.x + renderer[i].bounds.extents.x) + yPadding),
                   objectsToNumber[i].transform.position.y,
                     objectsToNumber[i].transform.position.z
                   );
              }
  
              newText.transform.position = newPos;
              newText.transform.parent = transform;
              newText.name = i.ToString();
              newText.tag = "Number";
              newTexts.Add(newText);
              var textmesh = newText.GetComponent&lt;TextMesh&gt;();
              textmesh.transform.localRotation = Quaternion.Euler(0, -90, 0);
  
              if (textAbove == true)
              {
                  textmesh.text = i.ToString();
              }
  
              if (textInFront == true)
              {
                  textmesh.text = "Hello World";
              }
          }
      }
  
      private void Update()
      {
          if (rotateNumbers == true)
          {
              for (int i = 0; i &lt; newTexts.Count; i++)
              {
                  newTexts[i].transform.Rotate(Vector3.up, 10 * rotationSpeed * Time.deltaTime);
              }
          }
      }
  }
  </code></pre>
  
  <p>Update :</p>
  
  <p>Trying using TextMeshPro :</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEngine;
  using UnityEngine.UI;
  using TMPro;
  
  public class AddTextToObject : MonoBehaviour
  {
      public UnityEngine.GameObject[] objectsToNumber;
      public UnityEngine.GameObject text;
      public float yPadding;
      public bool rotateNumbers = false;
      public float rotationSpeed = 10f;
      public bool textChild = false;
      public bool textAbove = false;
      public bool textInFront = false;
      public bool textOnFaces = false;
  
      private List&lt;GameObject&gt; newTexts = new List&lt;GameObject&gt;();
      private MeshRenderer[] renderer;
      private Vector3 newPos;
  
      private void Start()
      {
          renderer = new MeshRenderer[objectsToNumber.Length];
  
          for (int i = 0; i &lt; objectsToNumber.Length; i++)
          {
              GameObject newText = Instantiate(text);
              renderer[i] = objectsToNumber[i].GetComponent&lt;MeshRenderer&gt;();
  
              if (textAbove == true)
              {
                  newPos = new Vector3
                  (
                   objectsToNumber[i].transform.position.x,
                   ((objectsToNumber[i].transform.position.y + renderer[i].bounds.extents.y) + yPadding),
                     objectsToNumber[i].transform.position.z
                   );
              }
  
              if (textInFront == true)
              {
                  newPos = new Vector3
                  (
                   ((objectsToNumber[i].transform.position.x + renderer[i].bounds.extents.x) + yPadding),
                   objectsToNumber[i].transform.position.y,
                     objectsToNumber[i].transform.position.z
                   );
              }
  
              newText.transform.position = newPos;
              newText.transform.SetParent(transform, false);
              newText.name = i.ToString();
              newText.tag = "Number";
              newTexts.Add(newText);
              var textmesh = newText.GetComponent&lt;TextMeshProUGUI&gt;();
              textmesh.transform.localRotation = Quaternion.Euler(0, -90, 0);
  
              if (textAbove == true)
              {
                  textmesh.text = i.ToString();
              }
  
              if (textInFront == true)
              {
                  textmesh.text = "Hello World";
              }
          }
      }
  
      private void Update()
      {
          if (rotateNumbers == true)
          {
              for (int i = 0; i &lt; newTexts.Count; i++)
              {
                  newTexts[i].transform.Rotate(Vector3.up, 10 * rotationSpeed * Time.deltaTime);
              }
          }
      }
  }
  </code></pre>
  
  <p>But the result is that the text is not close to the gameobjects. 
  The text "Hello World" should be like stick/attached to each gameobject.</p>
  
  <p><a href="https://i.stack.imgur.com/XR8aR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XR8aR.jpg" alt="Text"></a></p>
  
  <p>And</p>
  
  <p><a href="https://i.stack.imgur.com/1fbNh.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1fbNh.jpg" alt="Text"></a></p>
  
  <p>And what I want to do is to stick/attach the text "Hello World" to the face front side of each of the 3 cubes New Game, Options, Quit :</p>
  
  <p><a href="https://i.stack.imgur.com/FSfdE.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FSfdE.jpg" alt="Text"></a></p>