- Home /
Mouse over make object Visible
Hello i am new to unity, and I am still learning.
I am currently developing a menu, in this menu i have a background which is a image assigned to a plane. I made 3D text ( start, Credits, and Exit. behind each text i have set up planes with a texture assigned to it.
What i want to do is when i hover over my text or even just the area I want to make the plane behind the text visible, and when i am not over it, i want it to be invisible.
The text is not grouped to the plane
I need some Code that will make this possible.
could anyone help.
thank you Thomas
Answer by azmat786n · Dec 04, 2012 at 05:05 AM
make your background using gui texture and also make buttons using gui texture
function OnGUI() {
/*
if(GUI.Button(Rect(x,y,width,height), Texture or "Text Strings"
*/
if(GUI.Button(Rect(10,10,100, 50), "Button1")) {
//make function here
doSomething();
}
if(GUI.Button(Rect(10,700,100, 50), "Button2")) {
//make function here
doSomething();
}
}
//// other tutorial you can find on youtube or unity3dstudent.com
I don't want to use GUI buttons, how would I use this by what I have ???
if i would use the GUI, how would I set the position and scale of the button??
if(GUI.Button(Rect(xPosiotion, yPosition, ButtonWidth, ButtonHeight), ButtonTextOrTexture)) { call a function(); }
well if i click on the button it will trigger a animation on a different object. I just have to add the name of the object with the animation attached to it. ?
Answer by azmat786n · Dec 04, 2012 at 07:38 PM
create guiskin right click inside project tab select create then click on guiskin. now select your gui skin just created look on inspector
expend (button>normal) select texture and text color.
expend (button>over) select as above.
expend (button>active) same as above.
now make a game object. put below script on that object.
//select gui skin from inspector
var guiskin:GUISkin;
function OnGUI() {
//setup gui skin to gui menu
if(GUI.Button(Rect(Screen.width/2-100,Screen.height/2-100,50,200), "Start")) {}
if(GUI.Button(Rect(Screen.width/2-100,Screen.height/2,50,200), "Credits")) {}
if(GUI.Button(Rect(Screen.width/2-100,Screen.height/2+100,50,200), "Quit")) {}
}
it can do that you want.. remove background texture from button>normal from guiskin. now when you mouse over on any button texture will show ..