- Home /
 
GUI Transparency Changing automatically
Hi all, I am currently working on a menu for a game however it keeps applying a transparency to my GUI elements (label, Box, Ext). I just want a solid image background. What can I do to fix this? Here is my code. Thanks!
if(showMenu) {</p> <pre><code> GUI.Label(Rect(0, -5, 1056, 780), MainMenuSkin); if(GUI.Button(Rect(Screen.width - 375, Screen.height - 600, 250, 50), "link4")) { popupToggle("Comming in Version Two!"); } if(GUI.Button(Rect(Screen.width - 375, Screen.height - 500, 250, 50), "link3")) { popupToggle("Comming in Version Two!"); } if(GUI.Button(Rect(Screen.width - 375, Screen.height - 400, 250, 50), "link2")) { popupToggle("Comming in Version Two!"); } if(GUI.Button(Rect(Screen.width - 375, Screen.height - 300, 250, 50), "link1")) { popupToggle("Comming in Version Two!"); } if(GUI.Button(Rect(Screen.width - 375, Screen.height - 200, 250, 50), "Return to Game")) { toggleControl(false); showMenu = false; } if(GUI.Button(Rect(Screen.width - 375, Screen.height - 100, 250, 50), "Quit Game")) { Application.Quit(); }  
Answer by Uzquiano · Apr 30, 2011 at 06:05 PM
Hi,
You can apply a GUIStyle to your GUI elements, for example
GUI.Button(Rect(Screen.width - 375, Screen.height - 100, 250, 50), "Quit Game",GuiStyle)
 
               
               I put you here how to do a GUIStyle:
var GuiStyle : GUIStyle; GuiStyle.alignment = TextAnchor.MiddleCenter; GuiStyle.normal.textColor = Color.white; private var tex; private var colors;
 
               function Start(){
 
                tex = new Texture2D(2, 2);
 colors = new Color[4];
 for (color in colors) color = Color.grey;
 tex.SetPixels(colors);
 tex.Apply();
 GuiStyle.normal.background = tex;
 
               } 
 
              Answer by DaveA · Apr 30, 2011 at 05:04 PM
Put GUIStyles on them http://unity3d.com/support/documentation/ScriptReference/GUIStyle.html You can control such things much like CSS for HTML.
Your answer
 
             Follow this Question
Related Questions
How to make a GUI Texture (image) transparent? 2 Answers
Reduce Draw call for Multiple GUI Textures with same Texture 1 Answer
Move GUI elements. 0 Answers
GUITexture Button? 1 Answer
Alpha not working in GUITex 0 Answers