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