首页 > 其他 > 详细

双击销毁物体

时间:2018-09-18 18:15:19      阅读:116      评论:0      收藏:0      [点我收藏+]
 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     }

 

双击销毁物体

原文:https://www.cnblogs.com/y1016/p/9670357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!