- Home /
Change color of Gui.Box background to solid black
Hey there,
I want to change the background Color of one particular Gui.Box in a Menu from a multiplied black to a solid black.
I know about Guistyles and creating own elements and also changing the color of an individual text element but with black this is not possible. I belive there is an easy solution via code like :
GUI.color = Color.black;
GUI.Box(Rect(10, 50, 50, 50), "A BOX");
GUI.color = Color.white;
At the moment my workaround( I know it is a very bad approach) is to have more than one Gui.Box in a row to get a darker black:
GUI.Box(Rect(10, 50, 50, 50), "A BOX");
GUI.Box(Rect(10, 50, 50, 50), "A BOX");
GUI.Box(Rect(10, 50, 50, 50), "A BOX");
But if I use this a few times the Draw Calls are exploding, has someone an idea how to disable the multiply of Color for one GuiBox, in an easy and quick way?
Answer by Eric5h5 · Nov 22, 2011 at 07:22 PM
Use a custom GUIStyle or GUISkin.
GUI.Box(Rect(10, 50, 50, 50), "A BOX", myStyle);
or
GUISkin = mySkin;
GUI.Box(Rect(10, 50, 50, 50), "A BOX");
Sorry, maybe I explainded it a bit unclear that I want to avoid using an new GUIStyle or GUISkin, just changing from color.black.multiply to color.black.solid ! -But I belive if You had known a better or faster way of doin it you already had said it before :)
If you don't want to use a GUIStyle, you could just use:
GUI.DrawTexture(someRectangle, someBlackImage);
You could then draw your box on top of that with no background image.