Question by
xVortexXz · Mar 12, 2017 at 06:14 PM ·
scripting problem
Change text based on which object is being hovered
I want to make a script which updates the description of each object when hovering the mouse over them. But it looks like only the first object is updated and the text stays the same when hovering other objects, until that object is destroyed.
public UnityEngine.UI.Text itemName;
public UnityEngine.UI.Text itemDescription;
public GameObject Upgrade_Description_Panel;
public bool displayInfo = false;
public string _itemName;
public string _itemDescription;
private void Update()
{
itemName.text = _itemName + "Cost: " + Manage.cost;
itemDescription.text = _itemDescription;
}
public void toggleDisplayInfoOn()
{
displayInfo = !displayInfo;
SetInfoVisibility();
Update();
}
Comment