根据设备不同选择不同触摸响应对象

function Update () {

	var clickDetected : boolean;
	var touchPosition : Vector3;

	if (Application.platform == RuntimePlatform.IPhonePlayer)
		isTouchDevice = true;
	else
		isTouchDevice = false;

	// Detect click and calculate touch position
	if (isTouchDevice) {
		clickDetected = (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began);
		touchPosition = Input.GetTouch(0).position;
	} else {
		clickDetected = (Input.GetMouseButtonDown(0));
		touchPosition = Input.mousePosition;
}

你可能感兴趣的:(根据设备不同选择不同触摸响应对象)