How to hide the grey GUI rectangle?

Hi

I now there are many new questions about how to work with GUI, while there are plenty of answears out there covering many of thoose already. But i dont find any answear on how to hide the grey GUI rectangle itself. I havent really found that kind of answear im looking for. It also seems that some people claims that this not even would be possible to do.

I have uploaded a picture of my GUI button, a grey standard rectangle with a image (of a green button) applied. So what i would like to do is just to hide the grey button, so the only thing you see is the green button image.

This is the javascript iam using, where Texture is the image iam using:

function OnGUI ()
{
GUI.Button(Rect(position.x, position.y, size.x,size.y),texture);
}

1063134--39518--$Skärmavbild 2012-10-17 kl. 20.50.37.png

I think your best solution would be to create a custom style.

GUI.backgroundColor = new Color(R, G, B, Alpha);

for for you it would be new colour(0,0,0,0);

1 Like

This method would also work well

Great!

Poppers code was exactly what as was looking for :smile:

Thank you both!

public GUISkin mySkin;

function OnGUI ()
{
  GUI.Button(Rect(position.x, position.y, size.x,size.y), "", mySkin.button); // "" for no text
}

Edit the “button” style in your skin (replace default background textures) and drag your skin to mySkin variable of your script.

This method enables the usage of 4 (actually up to 8) button states: normal, hover etc.