现在的位置: 首页 > 综合 > 正文

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

2013年09月26日 ⁄ 综合 ⁄ 共 424字 ⁄ 字号 评论关闭
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;
}

抱歉!评论已关闭.