标签:
1 void Update () { 2 //判断鼠标左键是否按下其没有按下UGUI物体 3 if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) { 4 //获取由主摄像机位置到鼠标点击位置的一条射线 5 Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition); 6 RaycastHit hitInfo; 7 //bool isCollider = Physics.Raycast (ray, out hitInfo,1000,LayerMask.NameToLayer("Ground")); 8 bool isCollider = Physics.Raycast(ray,out hitInfo); 9 //Debug.Log (isCollider); 10 //判断射线是否成功发射且是否触发目标物体 11 if (isCollider && hitInfo.collider.tag == "Ground") { 12 //参数为目标物体的位置信息 13 ShowClickEffect (hitInfo.point); 14 isMoving = true; 15 LookAtTarget (hitInfo.point); 16 //Debug.Log ("007"); 17 } 18 }
标签:
原文地址:http://www.cnblogs.com/yuge790615/p/5594223.html