- Home /
 
Constantly print a number from another script on 3D Object Text
I wanna print a float from another script on a text mesh pro 3D object. On that script, attached to an object, the float goes down each time the player presses a button, so this TMP object has to update constantly. Here is the only line i got, that does nothing:
         GetComponent<TextMeshPro>().text = GetComponent<SmashButton>().smashNo.ToString();
 
               As far as i read, this shouldve worked, but no dice. I hope this isnt too confusing, really.
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by LulaCD · Jul 04, 2020 at 12:39 AM
Nevermind, i forgot to call the button, so im just trying to get the script and its variable from the text itself.
 public class DisplaySmash : MonoBehaviour
 {
     public GameObject button;
     // Start is called before the first frame update
     void Start()
     {
 
     }
 
     // Update is called once per frame
     void Update()
     {
         GetComponent<TextMeshPro>().text = button.GetComponent<SmashButton>().smashNo.ToString();
     }
 }
 
               yeah.
Your answer