Invisible GUI

Hi,

My User Interface for my menu screens is one image and the buttons are part of the image, what is the best way to make these buttons clickable, should I use use a rectangle and check if a user has pressed the area or is there a way to make the unity GUI buttons see through and place them over the background image?

All GUI commands take an optional style - if you use GUIStyle.none, they become transparent. E.g.:

var background : Texture2D;
function OnGUI () {
    // Draw the background texture
    GUI.DrawTexture (Rect (0,0, background.width, background.height), background);

    // Make the invisble button
    if (GUI.Button (Rect (0,0,100,100), "", GUIStyle.none))
        Debug.Log ("Invisble button pressed");
}

Cheers, but the line:

if (GUI.Button (Rect (0,0,100,100), “”, GUIStyle.none))

Just crashes unity…

anyone know how to make a button with no style that wont crash unity?

Are you using a compressed texture? Because that definitely crashes the web player if used in a GUI.Button, GUI.TextArea, GUI.Label, etc.

Make sure you check your image settings and change the format from DXT1 and DX5 to RGB or RGBA.

@tgraupman:
Which browser/OS/graphics card does this? I know of tons of game that use compressed textures just fine in their GUI, so I’d like to know a lot more :slight_smile:

Could you submit a bugreport from the machine that crashes - including a built webplayer and the project it came from? Sorry if it seems a bit excessive, but this is the first I’ve heard of it, so I’d like to get as much info as possible.

Oh, and do tell me the bug number, so I can keep a lookout as it comes in.

Thanks,
Nicholas

Sorry to hijack your thread. It turns out IIRC that the compressed bug was fixed in Unity 2.5.

140636–5140–$compressedtextureingui_148.zip (1.11 MB)