unity怎么用射线激活ugui的按钮
1个回答
展开全部
Vector3 direc = (transform.position - curMainCamera.transform.position).normalized;
//Ray cameraRay = curMainCamera.ScreenPointToRay (new Vector3(Screen.width/2,Screen.height/2,0));
if (Physics.Raycast (curMainCamera.transform.position, direc,out hit, 1000)) {
Debug.DrawLine (curMainCamera.transform.position,hit.collider.gameObject.transform.position,Color.red,1000f);
if (hit.collider.gameObject.layer == layerCanSelected) { //被碰撞物体是UI条件
curSelectedObj = hit.collider.gameObject;
//Ray cameraRay = curMainCamera.ScreenPointToRay (new Vector3(Screen.width/2,Screen.height/2,0));
if (Physics.Raycast (curMainCamera.transform.position, direc,out hit, 1000)) {
Debug.DrawLine (curMainCamera.transform.position,hit.collider.gameObject.transform.position,Color.red,1000f);
if (hit.collider.gameObject.layer == layerCanSelected) { //被碰撞物体是UI条件
curSelectedObj = hit.collider.gameObject;
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
微测检测5.10
2023-05-10 广告
2023-05-10 广告
您好!建议咨 深圳市微测检测有限公司,已建立起十余个专业实验室,企业通过微测检测就可以获得一站式的测试与认 证解决方案;(EMC、RF、MFi、BQB、QI、USB、安全、锂电池、快充、汽车电子EMC、汽车手机互 联、语音通话质量),认证遇...
点击进入详情页
本回答由微测检测5.10提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询