标签:sans npoi touch mouse scree tin tor amp raycast
1 void Update () {
2
3 if (Input.GetMouseButtonDown(0))
4 {
5 //向屏幕发生一条射线
6 Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
7 RaycastHit hitInfo;
8 //如果碰到东西 返回射线信息
9 if (Physics.Raycast(ray, out hitInfo))
10 {
11 //touchCount手指的数量 Input.GetTouch(0).phase触摸的状态
12 if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)
13 {
14 //tapCount == 2 点击了2次
15 if (Input.GetTouch(0).tapCount == 2)
16 {
17 Destroy(hitInfo.collider.gameObject);
18 }
19 }
20 }
21
22 }
23 }
标签:sans npoi touch mouse scree tin tor amp raycast
原文地址:https://www.cnblogs.com/y1016/p/9670357.html