- Home /
The question is answered, right answer was accepted
How to make a GUI Texture (image) transparent?
Hello! I have a simple image made in GIMP that is gradient, green to white. I loaded this image into my code through the editor, and I need to edit the entire images' transparency.
My code to load it in is simple:
public Texture GPgreen;
I've assigned my image to that slot in the editor, and need to affect the whole things transparency. It is drawn as follows:
GUI.DrawTexture(new Rect(commonLeft + padding, commonTop + padding, healthBarLength
,healthBarHeight), tex1);
Any help is greatly appreciated. Thank you!
Answer by clunk47 · Nov 02, 2013 at 08:57 PM
Define your GUI color in the first line of you OnGUI function.
GUI.color = new Color32(255, 255, 255, 100);
Thanks for this! I was looking for a way to display correctly a sprite with alpha in Editor GUI. I finally came with this solution :
Color guiColor = GUI.color; // Save the current GUI color
GUI.color = Color.clear; // This does the magic
EditorGUI.DrawTextureTransparent(...);
GUI.color = guiColor; // Get back to previous GUI color
Answer by LividRabbit · Nov 02, 2013 at 07:26 PM
When you click on your Texture in the project panel, look in the inspector and change the Texture Type to GUI, you might also have to change the format to truecolor.
That didn't open up any more options for me... :/ It reduced it to 4 callable functions.
Follow this Question
Related Questions
Show GUI texture on collison 1 Answer
How to script GUI Texture Window to see it in Script (Object's component) 1 Answer
Pages overlapping problem 1 Answer
Gui Texture Swap? 1 Answer