Hello,
Simple question, How can I make a TextMeshPro prefab visible when instantiating?
I am doing a quick exercise to understand how Instantiate works with UI elements, in this case a TextMeshPro. I have created a Prefab (“one”) of my TextMeshPro and attached it to the “instantiate” script, when I press play the field where I attached my Prefab shows “none” which makes the prefab not visible. Please find the images below that exemplifies this:
Before pressing play:
While play mode:
My script looks like this:
public class Instantiate : MonoBehaviour
{
public TextMeshProUGUI text;
[SerializeField] private Transform spawnPoint;
// Start is called before the first frame update
void Start()
{
Instantiate(text, spawnPoint.position, spawnPoint.rotation);
text = GetComponent<TextMeshProUGUI>();
}
}
Thank you!