I am trying to instantiate a text object stating the new score when and where an object dies. I can instantiate the object but I can not see it in the game view until it is parented to the canvas. That’s where the trouble begins.
private Canvas canvas;
void Start()
{
pos = transform.position ;
Canvas thisCanvas = Canvas.FindWithTag("canvas");
canvas = thisCanvas.GetComponent<Canvas>();
}
public void killBubble ()
{
Destroy(gameObject);
ScoreManager.score += scoreValue;
Instantiate (scoreText, pos, Quaternion.identity);
scoreText.transform.parent = canvas.transform;
}
how can i find the canvas to make it a parent of the instantiated text object?
thanks in advance for your help