Gui Button

Hi, I’m new to using Unity GUI systems and have a question. When you create a GUI button with an image, the image is displayed in a visible border. Is there a way to prevent the border and background from being drawn (so it just draws the texture, but still detects the mouse click), or should I be using a different system (or a ray cast text onto a GUI texture)?

Thanks!

You should use GUI.Skin http://unity3d.com/support/documentation/ScriptReference/GUISkin.html

In the specific case you are after, you could just use the Label style:

if (GUILayout.Button("Click", "Label")) ...

But for full control, make a skin as Ludiares describes.

Another idea, is to use the GUI.Button as you were doing, but add an empty string at the end, and that removes the default button shape:

if (GUI.Button (Rect (100,100,60,60),texturename,“”)) works for me.

You can use a GUISkin, a GUIStyle, or you could draw a button using the default label style… like this:

if ( GUI.Button(someRect, someTexture, GUI.skin.label) ) {
    doStuff();
}

The best way to do it would be to create a GUIStyle and use your texture as the background image of its normal state.

Using a GUISkin is basically the same thing. It allows you to override all OR any of the GUIStyles used for the basic controls.

You can override a GUISkin’s button style or create your own style and add it to the customStyles field of the GUISkin.