Hi, all
Can we change opacity for texture witch is drawing as GUI.DrawTexture() ? :roll:
Hi, all
Can we change opacity for texture witch is drawing as GUI.DrawTexture() ? :roll:
GUI.color = someColorValue;
GUI.DrawTexture(...);
GUI.color = originalColorValue;
Just set the opacity you want as the alpha information in someColorValue (for example: new Color(1.0, 1.0, 1.0, 0.25) to have it set to 25%).
Thanks
Thanks HiggyB, even 3 years later it came in handy
A breakdown for those who want to know, the color class is Color (r,g,b,a). So you could have changed just the alpha (opacity) by setting:
GUI.color.a = yourAlpha; // value between 0 and 1
Thanks man, it’s really helpful.
Even 5 years later this is handy. Thanks HiggyB
Some things are useful no matter how old they are…
Well yep… thank you after 8 years
GUI.DrawTextureWithTexCoords should really come with a color parameter. It’s kinda silly to have to save the state of color yourself for other routines… At the very least GUI should come with a ‘save’ state.
GUI.Begin(State.color);
GUI.color = Color.red;
GUI.DrawTextureWithTexCoords(rect, texture, texCoords);
GUI.End();
Looks a lot better than:
Color someOldColor = GUI.color;
GUI.color = Color.red;
GUI.DrawTextureWithTexCoords(rect, texture, texCoords);
GUI.color = someOldColor;
Then again, just like the GUI.DrawTexture, a color could be included and make it even easier:
GUI.DrawTextureWithTexCoords(rect, texture, texCoords, color);
For those who’ll look for a solution: there is a GUI.DrawTexture() overload which gets a color, no need to change GUI.color:
Yup, like I stated GUI.DrawTexture() does have a color parameter, but the one with TexCoords does not… Though, upon reinspection, it looks like the OP doesn’t really care about using TexCoords… So GUI.DrawTexture() would indeed work for those that don’t need to use TexCoords and a color parameter.