Unity简单触屏判断
来源:互联网 发布:windows视频截gif 编辑:程序博客网 时间:2024/06/06 10:07
单手旋转,双手改变相机的view值(类似拉近放远)
if (Input.touchCount <= 0) { return; } if (Input.touchCount == 1) { /* if (Input.GetTouch(0).phase == TouchPhase.Moved && move) //触屏 { Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition; transform.Translate(touchDeltaPosition.x * Time.deltaTime * speed /3, touchDeltaPosition.y * Time.deltaTime * speed /3, 0f, Cam.transform); }*/ if (Input.touches[0].phase == TouchPhase.Moved) //触屏移动物体旋转 { if (Input.touchCount > 1) { return; } float x = Input.touches[0].deltaPosition.x / 3; float y = Input.touches[0].deltaPosition.y / 3;
//我这里尝试用float y = Input.GetAxis("Mouse Y");也可以使用,但是有时候会出现放大完毕后,突然旋转某个角度,下面附上大概原因的链接,但是改为这种,感觉有时候也会,但是概率小了很多。 transform.RotateAround(Vector3.up, Time.deltaTime * x); transform.RotateAround(transform.right, -Time.deltaTime * y); return; } } else if (Input.touchCount >= 2) { Touch newTouch1 = Input.GetTouch(0); Touch newTouch2 = Input.GetTouch(1); if (newTouch2.phase == TouchPhase.Began) { oldTouch1 = newTouch1; oldTouch2 = newTouch2; return; } float oldDistance = Vector2.Distance(oldTouch1.position, oldTouch2.position); float newDistance = Vector2.Distance(newTouch1.position, newTouch2.position); float offset = newDistance - oldDistance; float scaleFactor = offset / 10f; float Camview = Cam.GetComponent<Camera>().fieldOfView - scaleFactor; if (Camview >= MixCameraView && Camview <= MaxCameraView) { Cam.GetComponent<Camera>().fieldOfView = Camview; } oldTouch1 = newTouch1; oldTouch2 = newTouch2; return; }
//大致原因链接:http://blog.csdn.net/poda_/article/details/51334051
0 0
- Unity简单触屏判断
- unity 简单手势判断(一)
- unity 实现简单的触屏功能
- Unity判断当前鼠标顺逆时针旋转的简单算法
- unity判断网络状态
- Unity平台判断
- unity判断联网
- Unity运行平台判断
- unity实现判断手指是否顺时针滑动实现简单的方向盘效果
- Unity判断网络连接状况
- 【Unity】怎么判断鼠标双击
- Unity - 判断当前所属平台
- unity各平台判断条件
- Unity 判断当前网络类型
- Unity 判断鼠标上下左右拖动
- Unity 线,面 相交判断
- Unity 判断两次时间间隔
- Unity简单AI编写
- DP-编辑距离问题
- 简单计算 (sdut oj)
- 求1+2+3+...+n(逻辑题)
- (五)play之yabe项目【评论】
- Android-Matrix矩阵
- Unity简单触屏判断
- SDWebImage源码解读 之SDWebImageDownloaderOperation
- python 界面编程 并执行sh命令
- 存储过程与触发器的区别
- codeforces 760E or 759C 【线段树维护后缀和】
- 三 . css语法、样式表
- PAT甲级1032
- 重载与重写
- spring boot 学习(五)SpringBoot+MyBatis(XML)+Druid