I am extreme newbie and I have been doing a ton of tutorials, but I seem stuck in this area.
Basically I am writing a script where when the mouse goes over a specific object it displays text to the user. ( the geometry does have a collider)
var text = "Are you sure?";
function OnMouseOver ()
{
guiText.text = "Are you sure?";
}
I have a guiText component attached to the object with the text stating Are you sure? The component is enabled.
I then attach the script to the object also. Once I am in the game and my mouse goes over the object nothing displays on the screen and the listener window does not even show that the mouse has gone over the object.
I am really confused and looking for advice so please don’t pound me.
GUILayer component is required on the camera to display GUI elements (it should be already present).
The position of the GUIText is relative to the value transform.position (can be seen and changed in the Inspector, component Transform, Position field). It means, for a position of (0.0, 0.0, 0.0), the GUIText is at the … bottom left of the screen. At (1.0, 1.0, 1.0), it is a the top right.
The Z value of the position is the depth (from my memories).
Since I highly doubt your cube position X is between 0.0 AND 1.0, and your cube position Y is between 0.0 and 1.0, it will be outside the screen.
You would make a variable of type GUIText on your cube, make an empty game object with GUIText component, and drag and drop that object in the GUIText variable of the cube.
public var guiTextDisplay : GUIText;
function OnMouseEnter ()
{
guiTextDisplay.text = "Are you sure ?"
}
function OnMouseExit ()
{
guiTextDisplay.text = "";
}
var guiTextDisplay :GUIText;
function Update ()
{
}
function OnMouseEnter ()
{
guiTextDisplay.text = "Are you sure?";
}
function OnMouseExit ()
{
guiTextDisplay.text = "";
}
Originally I did not include the function Update.
So without the function Update, the scrip would display the text on the mouse over, then the text would disappear after the mouse exit. The problem was that when the mouse went back over it would not display the text again.
So here is my question.
Is an empty function Update required if you are looking for these results or is there a way to script this without the function Update?
I am still learning but I can tell you taking the time to figure out the last problem on my own, although very simple, was extremely gratifying.
Your help has been invaluable to me as a beginner.