I thought the code below would implement multitouch but am told it registers only one finger down at a time. I am assuming that each finger when touching enables the touchphase.begin and will implement the code in the loop for all touches in the array. I do not have a device to test on so I set the useMouse variable true for iterative testing and false when I compile for it to be tesed on a device that is touch enabled.
var useMouse : boolean;
var levelCtrl : LevelController;
function Update () {
// Code for OnMouseDown in the iPhone. Unquote to test.
var hit : RaycastHit;
if (!useMouse) {
for (var i = 0; i < Input.touchCount; ++i) {
if (Input.GetTouch(i).phase == TouchPhase.Began) {
// Construct a ray from the current touch coordinates
var ray = camera.ScreenPointToRay (Input.GetTouch(i).position);
if (Physics.Raycast (ray,hit)) {
print (hit.transform.gameObject);
var hexagonName = hit.transform.gameObject.name;
levelCtrl.FlipTileToObverse (hexagonName);
}
}
}
} else if (Input.GetMouseButtonDown(0) && useMouse) {
ray = camera.ScreenPointToRay (Input.mousePosition);
if (Physics.Raycast (ray,hit)) {
//print (hit.transform.gameObject);
hexagonName = hit.transform.gameObject.name;
levelCtrl.FlipTileToObverse (hexagonName);
}
}
}