in my game I have several house groups (see image below), I want to show a specific message when the mouse hovers a specific house group.
For some reason, this only works on the first switch case (house) but fails on the second switch (house2). The default case doesn't work either. I verified that the case house2 is found by the engine. By not working I mean the text does not appear.
Do you have any idea about the problem?
Image:
Code:
public class MouseIsOver : MonoBehaviour {
private Image TipImage;
private Text textObject;
public string text;
private bool displayInfo;
void Start ()
{
TipImage = GameObject.Find("realtyInformation").GetComponent<Image>();
textObject = GameObject.Find("realtyInformationText").GetComponent<Text>();
TipImage.enabled = false;
}
{
Display();
}
private void OnGUI()
{
}
void Display ()
{
if (displayInfo)
{
switch (text.ToLower())
{
case "house":
textObject.text = "house text1";
break;
case "house2":
textObject.text = "house text2";
break;
default:
textObject.text = "Click on the building";
break;
}
}
else
{
TipImage.enabled = false;
textObject.text = "";
}
TipImage.enabled = true;
}
private void OnMouseOver()
{
displayInfo = true;
}
private void OnMouseExit()
{
displayInfo = false;
}
}