x


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.

more ▼

asked Aug 12 '12 at 07:04 PM

Sausagesauce gravatar image

Sausagesauce
18 3 5 9

post it as answer to close question

Aug 12 '12 at 10:18 PM ScroodgeM
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first
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.

more ▼

answered Aug 19 '12 at 09:40 PM

Sausagesauce gravatar image

Sausagesauce
18 3 5 9

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3694
x985
x380
x72
x28

asked: Aug 12 '12 at 07:04 PM

Seen: 809 times

Last Updated: Aug 19 '12 at 09:40 PM