- Home /
Remove Button Border
I would like to load a GUI.Button so that only the image assigned to it appears without the frame of the button on the screen. Is this possible?
Take a look at GUIStyle. You'll be able to customize everything from there for your GUI elements.
http://unity3d.com/support/documentation/ScriptReference/GUIStyle.html
Answer by gaps · Jul 11, 2014 at 02:25 PM
The best and simplest solution is to use what you may call the blank style. This works with text and texture buttons and it also applies to other GUI elements.
You can create one by using new GUIStyle()
but the prefered way is to use the GUIStyle.none
static member. For example:
GUI.Button(someRect, someText, GUIStyle.none);
for a great answer. From Dannysim's comment I knew to look in GUIStyle, and once I got there, after reading over the docs for several $$anonymous$$utes, I decided to try GUIStyle.none, and found it worked perfectly. If only your answer had been upvoted, I would have tried it and saved myself the trouble. I actually returned here with the plan of adding this answer, but then I saw your answer at the bottom, so I upvoted it, and I down voted jahroy. So now hopefully your answer, the best answer, will appear at the top. Edit: $$anonymous$$eh, it's the #2 answer after my votes. Still, as soon as one other person up votes this, it'll be #1.
Answer by jahroy · Dec 06, 2011 at 10:25 PM
Like dannyskim says, take a look at GUIStyles to fully customize everything about your GUI elements.
You could also draw a button using the Label style like this:
/* get the label style from the current GUI skin */
var labelStyle : GUIStyle = GUI.skin.label;
GUI.Button(someRect, someText, labelStyle);
The default GUIStyle for labels has no frame or image associated with it.
-1: Just use GUIStyle.none as gaps says in their answer. This one just abuses the GUILabel's default style, which could theoretically someday change to include a border graphic.
Answer by Ghnxyc · Jul 20, 2013 at 01:01 PM
Try putting this piece of code: GUI.backgroundColor = new Color(0,0,0,0); infront of your GUI.Button code.
for example:
//back button
GUI.backgroundColor = new Color(0,0,0,0);
if(GUI.Button(new Rect(5*Screen.width/100-Screen.height/12, 44*Screen.height/50, Screen.height/8, Screen.height/8), BackButton))
{
/*go back;*/
}
It worked for me.
Your answer
Follow this Question
Related Questions
GUIStyle Border Pixels 0 Answers
Why can't I access the Name field in the Custom Styles section of a GUISkin in the Inspector? 2 Answers
Why is texture blurred in one GuiStyle and not in another? 1 Answer
Problems controlling the GUI skin / style 2 Answers
Understanding GUISkin/GUIStyle BackgroundImage and Border 2 Answers