Making a button in unity iphone?

Ok I know how to make the boring buttons like:

if (GUI.Button(Rect(20,50,10,30),"Click"))

or with texture:

if (GUI.Button(Rect(10,10,50,50),btnTexture))

But how to transform a Gui texture into a button? (without using guiskin) That kind of things really improve the user experience. I know it is simple but how?

...boring buttons...

I just ignored that... :D

Well you want to use a GUTTexture. Just place a script on that gameobject that contains the GUITexture and use something like that:

Doesn't work on iPhone:

// Javascript
function OnMouseDown() {
   // I just get clicked!
}

function Update(){
   if (Input.touchCount>0)
   {
      foreach(Touch T in Input.touches)
      {
         if(T.phase = TouchPhase.Began && guiTexture.HitTest(T.position))
         {
            // Just touched the GUITexture
         }
      }
   }
}

You don't need to use TouchPhase.Began, you can also use TouchPhase.Ended

Hey guys I found a simple and cool way on how to create a button,I have seen this question like 6 or 7 times and there wasnt a correct answer anywhere.

Finally the the answer:

var recoveryTime = 10;

private var delay = 0;

function Update () { if (delay>0){delay -=1;}

          if (delay == 0){            if (iPhoneInput.touchCount ==1){

          var currentTouch:iPhoneTouch = iPhoneInput.touches[0]; 

      if(currentTouch.phase ==

iPhoneTouchPhase.Began && guiTexture.HitTest(currentTouch.position)){ Application.LoadLevel ("FirstLevel");

     }
   }
          }    }

I hope it helps guys, just add the code to the GUI texture.

If this helps you, dont forget to rate....:)

Try this:

function Update () {    
    var fingerCount = 0;
    for (var touch : Touch in Input.touches) {
        if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled && guiTexture.HitTest(touch.position))
            fingerCount++;
    }
    if (fingerCount > 0) {
        // your action goes here....
    }
}