OnMouse menu on iphone

Hi,

I am currently trying to work on a simple menu system for the iphone. I have made one with the help of the tornado twins tutorial, but I really want it to work on the iphone.This is my code so far…

var isQuitBtn = false;

function OnMouseEnter ()
{
renderer.material.color = Color.red;
}

function OnMouseExit ()
{
renderer.material.color = Color.white;
}

function OnMouseUp()
{
if(isQuitBtn)
{
Application.LoadLevel(0);

}

else

{

Application.LoadLevel(1);

}

}

I have read about an ‘Emulator’ type code which works for OnMouse (written by technicat). How would I go about using this code to work on the iphone.

function Update () { 
   var hit : RaycastHit; 
   for (var i = 0; i < iPhoneInput.touchCount; ++i) { 
      if (iPhoneInput.GetTouch(i).phase == iPhoneTouchPhase.Began) { 
      // Construct a ray from the current touch coordinates 
      var ray = camera.ScreenPointToRay (iPhoneInput.GetTouch(i).position); 
      if (Physics.Raycast (ray,hit)) { 
         hit.transform.gameObject.SendMessage("OnMouseDown"); 
      } 
   } 
   } 
}

Thanks

Sunnee

hmmmmm If you want a simple menu I reccommend using this script and attaching it to a GUI Texture. There are different thoughts on what seems to work, but this script worked fine when i attached it to a GUI Texture. This is not my script so I shouldnt take credit for it.

Jfrost

var isQuitBtn = false;





function Update() { 
    
    
   if(iPhoneInput.touchCount > 0) 
   { 
      var touch: iPhoneTouch = iPhoneInput.touches[0]; 

       if(touch.phase == iPhoneTouchPhase.Began  guiTexture.HitTest(touch.position)) 
        
       { 
	   
	   
	   
	   


	if(isQuitBtn)
	{
		Application.Quit();
		
		}
		
		else
		
		{
		
		Application.LoadLevel(1);
		
	}
		
		
}
	
   }
   
   
}