- Home /
Gui Button Solid
I am using the following script to make a gui button. How can I edit the transparency of this button?
function OnGUI () {
if (GUI.Button (Rect (25, 25, 500, 50), "Play")) {
}
goodness, you don't know who Hideo $$anonymous$$ojima is ?!
that would be like being an aspiring filmmaker and not knowing about Jaws or Pretty Woman ! heh !
"$$anonymous$$etal Gear Solid", 10 million sales, top ten or twenty game of all time. It is a, or I suppose the, "s$$anonymous$$lth" title. (a "s$$anonymous$$lth" is like an FPS but you can hide behind boxes.) (personally, i have no interest in fps, they are silly, but it's a masterwork of course)
http://blogs.ocweekly.com/heardmentality/2010/03/the_5_most_badass_japanese_game_designers.php
O$$anonymous$$ "$$anonymous$$etal Gear Solid" is an incredibly famous video game, and your question title "Gui Button Solid" sounds humorously similar. You rock.
Answer by Bunny83 · Sep 01, 2012 at 12:52 AM
By using another skin. The transparency is part of the button texture itself. You can design your own buttons by creating a custom GUISkin and replace the textures with your own.
To use your skin you need to tell Unity to use it in OnGUI.
var mySkin : GUISkin; // assign your skin in the inspector
function OnGUI ()
{
GUI.skin = mySkin;
if (GUI.Button (Rect (25,25,500,50), "Play"))
// ...
}
Also if you use different styles then delete "GUI.skin = mySkin;" And add mySkin to the button ie: if(GUI.Button(Rect(25,25,500,50), "Play", mySkin))
I used this script, however the button appears unchanged.
I know. I made the GUI Skin and attached it to the button.
Would I have to add a texture to the background to make the button solid?
@Coreyf716: Exactly! As i said the background texture for most default gui elements is a transparent texture. Also the default skin is quite simple you can probably make a way better one ;)
@landon91235: You can't use a GUISkin as parameter for any GUI function. You can pass a certain GUIStyle, but this has to be created somewhere. Either use a certain style from a GUISkin or create the style manually via code. A GUISkin is much simpler most the time. You can also define custom styles in a Skin and just use the style name in the button.
GUI.Button (Rect (25,25,500,50), "Play", "mycustomstyle");
mycustomstyle needs to be defined in the current skin.
Answer by Eric5h5 · Sep 01, 2012 at 12:49 AM
Make a new style or skin with a solid button texture and use that in the button.
I am new to Unity code. I'm unsure of how to code the skin to react on click.
See the Unity docs for GUI code; everything is explained in detail.
Your answer
Follow this Question
Related Questions
GUIText Problem With MENU 1 Answer
Move the text in a GUI Button/Box 1 Answer
Gui Text Script 4 Answers
Alpha not working in GUITex 0 Answers
GUI Button Disappearing 1 Answer