title: Unity TextMeshProUGUI.text is NullReferenceException ... not set to an instance
body: <p>I've been looking around for a possible solution but I don't solve It... This is the problem:</p>
  
  <p>I have in a file with its class the various Ui, including the textmesh.</p>
  
  <p>Another file, with its own class, retrieves and sets them via ".text"</p>
  
  <p>result?</p>
  
  <blockquote>
    <p>"NullReferenceException: Object reference not set to an instance of an
    object Controller_RaceManager.Update () (at
    Assets/[GameAssets]/Controller
    [MobileCar]/Scripts.Code/Controller_RaceManager.cs:307)"</p>
  </blockquote>
  
  <p>to better understand:</p>
  
  <p>A) into Controller_UiManager.cs (attached to the canvas with all UIs)</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  
  using UnityEngine;
  using UnityEngine.EventSystems;
  using UnityEngine.UI; using TMPro;
  
  
      public class Controller_UiManager : MonoBehaviour
      {
  
  
  
          [System.Serializable]
          public class UiSettings
          { 
  
  
              public TextMeshProUGUI Label_Lap;
  
          }
          [SerializeField]
          [HideLabel] public UiSettings UiElements;
  
  
          void OnDrawGizmos()
          {
  
              var Canvas  = this.gameObject;
  
              UiElements.Label_Lap = getTheChild(Canvas, "Label.PilotLap").transform.GetComponent&lt;TextMeshProUGUI&gt;();
  
              // note: getTheChild is a method that returns the child gameObject
  
          }
  
  
      }
  </code></pre>
  
  <p>B) Controller_RaceManager.cs, which of course handles all the values ​​of races (It's attached to his prefab for loops and bla bla bla)</p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  
  using UnityEngine;
  using UnityEngine.UI; using TMPro;
  
  public class Controller_RaceManager : MonoBehaviour
  {
  
      [System.Serializable]
      public class RaceManagerSettings
      {
  
          ...
  
          public Controller_UiManager UiManager;
  
      }
      [SerializeField]
      [HideLabel] public RaceManagerSettings sets;
  
  
      void OnDrawGizmos()
      {
          if(GameObject.Find("Ui-RaceLoop"))
          {
              sets.UiManager = GameObject.Find("Ui-RaceLoop").transform.GetComponent&lt;Controller_UiManager&gt;();
          }
          else
          {
              Debug.LogError("Controller Race Manage: Ui System not founded - Ui-Raceloop prefab is not in scene");
          }
  
      }
  
      void Update()
      {
  
          string Label_Lap_Output = "";
          if(...)         { Label_Lap_Output = "FINISHED";}
          else if(....)   { Label_Lap_Output = "LAP XX/"+totalloopText; }
          else            { Label_Lap_Output = "LAP O"+pilotlapText+"/"+totalloopText; }
  
          sets.UiManager.UiElements.Label_Lap.text = Label_Lap_Output;
  
      }
  
  }
  </code></pre>
  
  <p>here unity pauses and gives notice. If I take the break, it continues quietly ... but am I becoming stupid?</p>
  
  <p>is there a reason?</p>
  
  <p>note: Unity <strong><em>TextMeshProUGUI.text is NullReference</em></strong> not "why not all or some things" ... but textmeshpro.</p>