Assigning Texture2D as GUI.Button

I'm attempting to create a custom GUI from an Illustrator file which will control character movement. Here is a sample of the script I'm attempting to build:

//  GUI active elements:
var dPadTexture : Texture2D;
var position :  Rect;

function OnGUI () {

   GUI.DrawTexture( position, dPadTexture );
   GUI.Button(position, dPadTexture);
}   

My question is how to draw a Texture2D in the GUI and have it also function as a button, basically just creating a custom button graphic that inputs as a mouseEvent telling the character to move.

Here is a screenshot of the above code's result:alt text

I think what you want is this:

GUI.Button(position, dPadTexture, "label")

This will create a button with the texture, and make it look like a label (no button border).

I can't really tell what you're asking. Your DrawTexture doesn't look like it's helping anything. And you need an if statement around your button code, if you want it to be functional and not just graphical.

http://unity3d.com/support/documentation/ScriptReference/GUI.Button.html

Edit: I'm assuming now that you're talking about the default style. Get rid of it.

var style : GUIStyle;

function OnGUI () {
   GUI.Button(position, dPadTexture, style);
} 

if (GUI.Button(new Rect(100, 10, 200, 250), nameofthebutton))
{}

This is my way, I do it like this:

1)Create GUISkin…

2)Write script, or copy and paste this JavaScript:

var Skin : GUISkin;

function OnGUI {
    GUI.skin = Skin;
    //button code...
}

Good Luck, Ivan!