- Home /
show gui when look certain object
hi i want that when im look with the cursor a box (a generally mesh) a gui appear , and when im no longer look it the gui disappear i had try several way with no succes. wath is a correct way to do that?
Do you want to show gui when the mouse cursor is over an object?
Answer by oliver-jones · Dec 01, 2010 at 03:02 PM
Well, I'm not sure how your scene is set up. But you could do something like this:
BoxScript (place this onto your box)
static var GUIon : boolean = false;
function OnMouseOver(){ GUIon = true; }
function OnMouseExit(){ GUIon = false; }
GUIScript (place this onto a game empty in scene)
function OnGUI(){
if(BoxScript.GUIon == true){
GUI.Box(Rect(0,0,Screen.width,Screen.height),"Cursor Over Object");
}
Answer by tigre · Dec 01, 2010 at 03:42 PM
yup the sistem is right wath i need thanks , i need to reply, then why this code
var im : GUITexture;
function OnGUI(){ if(showonbox.GUIon == true){ GUI.Box(Rect(0,0,Screen.width,Screen.height),im); } }
isnt correct? the debug tell me that gui.box dont have the approprieate engine for this..... i use the free unity..is this the problem?