Hello,
I am trying to create a button for my IOS game which for some reason I find harder then I would expect. I understand that it is not recommended to use OnGUI so I created a GUITexture with the following script attached to it.
#pragma strict
var playButton : GUITexture;
var level : String;
private var touch : Touch;
function Start () {
}
function Update () {
for (touch in Input.touches){
var buttonHitTest = playButton.HitTest(touch.position);
if(buttonHitTest touch.phase == TouchPhase.Ended){
Debug.Log("Play!!!");
Application.LoadLevel(level);
}
}
}
When I click this button it sometimes does what it is supposed to do but sometimes it doesn’t react at all, which off course is not the desired effect. Could someone maybe help me out here.
Kind Regards,
Max Uijlings