- Home /
Change GUI on mouse over
So, my Main Camera has a GUIText that appears as a period in the center of the screen. I want to change the period to an "o" when the camera mouses over a GameObject that has that script. The script is meant for the object in question, by the way! Here's the script.
var other : GameObject; //What object is this script subject to?
function OnMouseOver() { //Is the cursot over the object? other.guiText.text = "o"; //Change GUIText to "o" }
The script doesn't work, aside from not having any errors. The script runs fine, but the GUIText doesn't change!
EDIT: I have a new script that does work. It took me a long time, but it also changes the font color as well! Here's the code:
var object : GameObject;
private var textDisplay : GUIText;
function OnMouseEnter() {
object.guiText.material.color = Color.green;
object.guiText.text = "o";;
}
function OnMouseExit() {
object.guiText.material.color = Color.white;
object.guiText.text = ".";
}
So there you have it.
Answer by Sausagesauce · Aug 19, 2012 at 09:40 PM
var object : GameObject;
private var textDisplay : GUIText;
function OnMouseEnter() {
object.guiText.material.color = Color.green;
object.guiText.text = "o";;
}
function OnMouseExit() {
object.guiText.material.color = Color.white;
object.guiText.text = ".";
}
This is just to close the question.
Your answer
Follow this Question
Related Questions
Changing a material with a mouse click 2 Answers
detect mouseover with grid buttons? 1 Answer
Getting mouse over GUI event 0 Answers