- Home /
C# Applying Transparency to a Single GUI.Button
Hi everyone, how do you apply transparency to a single GUI.Button? GUI.Color applies it's color to every part of the GUI. I would like it to apply it to a single GUI.Button and not everything else. I looked at the documentation for GUI.Button and it doesn't mention a parameter for GUI.Color.
GUI.color = new Color(1,1,1,0.5f);
GUI.Button(new Rect(100, 10, 50, 50), "Transparent Button");
GUI.Button(new Rect(100, 70, 50, 50), "Nontransparent Button");
Answer by MaddyGm3R · Aug 28, 2013 at 05:21 AM
Hi You have to reset the color value before drawing the next button. Solution : store the prev color value stored in GUI.color, and when you have drawn your button, just reset it to the stored value.
e.g
Color temp = GUI.color;
GUI.color = new Color(1,1,1,0.5f);
GUI.Button(new Rect(100, 10, 50, 50), "Transparent Button");
GUI.color = temp;
GUI.Button(new Rect(100, 70, 50, 50), "Nontransparent Button");
This will make your buttons as you want.
Your answer
Follow this Question
Related Questions
C# Multiple GUI.Tooltips 2 Answers
C# Rows and Columns GUILayout.Window Issues 1 Answer
C# Boolean Doesn't Change Value 1 Answer
C# GUI.Tooltip If Statement 2 Answers