I got this script and want to use it on several items, but when I try, the text doesn’t show up anymore.
Every item gets their own canvas, but is there a better way? (The names show up above the object)
It works when I put it on 1 object. As soon as a try 2 the text will be gone.
public string myString;
public Text myText;
public float fadeTime;
public bool displayInfo;
private void Awake()
{
myText = GameObject.Find("Text").GetComponent<Text>();
myText.color = Color.clear;
}
private void Update()
{
FadeText();
}
private void OnMouseOver()
{
displayInfo = true;
}
private void OnMouseExit()
{
displayInfo = false;
}
void FadeText()
{
if (displayInfo)
{
myText.text = myString;
myText.color = Color.white;
}
else
{
myText.color = Color.clear;
}
}
}