纳金网

标题: 根据设备不同选择不同触摸响应对象 [打印本页]

作者: 王者再临    时间: 2015-2-26 15:36
标题: 根据设备不同选择不同触摸响应对象

根据设备不同选择不同触摸响应对象
  1. function Update () {

  2. var clickDetected : boolean;

  3. var touchPosition : Vector3;

  4. if (Application.platform == RuntimePlatform.IPhonePlayer)

  5. isTouchDevice = true;

  6. else

  7. isTouchDevice = false;

  8. // Detect click and calculate touch position

  9. if (isTouchDevice) {

  10. clickDetected = (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began);

  11. touchPosition = Input.GetTouch(0).position;

  12. } else {

  13. clickDetected = (Input.GetMouseButtonDown(0));

  14. touchPosition = Input.mousePosition;

  15. }
复制代码





欢迎光临 纳金网 (http://rs.narkii.com/club/) Powered by Discuz! X2.5