Check out example codes for "text variable type unity". It will help you in understanding the concepts better.

Code Example 1

using UnityEngine;
using UnityEngine.UI; //make sure to add this!

public class Script : MonoBehaviour
{
	public int counter = 0;
	public Text variable; //make reference in Unity Inspector Window
    
    void Update()
    {
    	counter++;
    	variable.text = "counter: " + counter;
    }
}

Learn ReactJs, React Native from akashmittal.com