- Home /
How can I get the Unity 3 texture for 'button on'?
I was able to get the Unity 2 builtin version here but it is not light enough for my project. I know I can use toggles to force the effect but I also want to set hovers and all button states to 'button on' for a custom style.
Alternatively, when I use a GUI.Button, I can select the style. Is there a way to call the style and the part of the style you need like
if (GUI.Button(Rect(10,10,50,50),"Hello",MyStyle_ButtonOn))
{
// do something;
}
Thank you
Answer by Anxo · May 29, 2011 at 05:21 PM
Oh and if you wanted a texture you dont use "" you just place the textures name in the name field
var picToUse : Texture2D;
if(GUI.Button(Rect(10,10,50,50),picToUse ,Mystyle))
{
doSomething();
}
picToUse is the foreground button texture here. I am looking for the background button texture. It may not be fixable in code. When I edit a GUISkin, I can choose my background skin for Button, but the builtin skins are not available, only files I have. What I need is the actual texture. A texture file equal to Unity 3's 'button on' background button texture.
Answer by Anxo · May 29, 2011 at 05:18 PM
if you look at the documentation it give you an example. Just type GUI in the docs or better yet just click on your GUI button in your code and hit the little question mark on the top. it will take you right to the page.
GUI buttons need to be in an if statement, when you hit it the statement is executed like
if(GUI.Button(Rect(10,10,50,50),"my button",Mystyle))
{
doSomething();
}