When I collect a power-up in my game I want to instantiate dynamic text (e.g. "Missile" or "Shield") at the power-up's location but my code doesn't work.
This is my function (I admit it 's a bit messy):
public Text upgradeTxtPrefab;
void ShowUpgradeTxt (string _upgradeTxt) {
// find canvas
GameObject canvas = GameObject.Find("Canvas");
Text tempUpgradeTxt = (Text)Instantiate (upgradeTxtPrefab);
tempUpgradeTxt.fontSize = 24;
tempUpgradeTxt.transform.position = this.transform.position;
tempUpgradeTxt.transform.SetParent (canvas.transform, false);
upgradeTxtPrefab.text = _upgradeTxt;
}