clmingxx 2020-02-28 15:02 采纳率: 0%
浏览 919

求助:Unity VR的UI问题

开发VR场景过程中
在**电脑调试**时效果如下:图片说明

图1

UI显示正常

射线检测会将FallBack小球放置于击中点

通过碰撞盒检测加载进度条并依照进度触发按钮或勾选框效果

而在**USB调试或真机测试**时效果如下:

图片说明

图2

UI显示没有遮挡效果

射线检测会将FallBack小球放置于击中点但不能加载进度条(图中为测试进度条设置最低进度10%)

代码:

if (Physics.Raycast(ray, out hitInfo, 100F))
        {
            sp.transform.position = hitInfo.point;
            //Debug.Log("UI层:"+ results.Count);
            if (hitInfo.transform.tag.Equals("货物"))
            {
                P_ring.GetComponent<Image>().color = Color.green;
                if (loading() >= 1)
                {
                    hitInfo.transform.position = cao_p.transform.position;
                    P_ring.GetComponent<Image>().fillAmount = 0;

                }
            }
            else if (hitInfo.transform.tag.Equals("地面"))
            {
                //P_ring.GetComponent<Image>().color = Color.grey;
                if (loading() >= 1)
                {
                    head.transform.position = new Vector3(hitInfo.point.x, head.transform.position.y, hitInfo.point.z);
                    P_ring.GetComponent<Image>().fillAmount = 0;

                }
            }
            else if (hitInfo.transform.tag.Equals("标签"))
            {
                P_ring.GetComponent<Image>().color = Color.yellow;
                //Debug.Log("标签");
                if (loading() >= 1)
                {
                    hitInfo.transform.parent.parent.gameObject.GetComponent<货架>().setoff();
                    P_ring.GetComponent<Image>().fillAmount = 0;

                }
            }
            else if (hitInfo.transform.tag.Equals("可触发"))
            {
                P_ring.GetComponent<Image>().color = Color.white;
                //Debug.Log("可触发");
                if (loading() >= 1)
                {
                    //hitInfo.transform.parent.parent.gameObject.GetComponent<货架>().setoff();
                    if (hitInfo.transform.name.Equals("Checkmark"))
                    {
                        hitInfo.transform.parent.parent.GetComponent<Toggle>().isOn = !hitInfo.transform.parent.parent.GetComponent<Toggle>().isOn;
                    }
                    else if (hitInfo.transform.name.EndsWith("按钮"))
                    {
                        hitInfo.transform.GetComponent<Button>().onClick.Invoke();
                    }
                    P_ring.GetComponent<Image>().fillAmount = 0;

                }
            }
            else
            {
                P_ring.GetComponent<Image>().fillAmount = 0.1f;
            }
            //Debug.Log("Shoot:" + hitInfo.transform.name);//loading();
        }

得出信息如下:
1. 射线在两种情况下都能检测到附加在UI组件上的盒型碰撞盒
2. 在USB调试或真机测试时不能检测碰撞盒所属gameobject的tag
3.在USB调试或真机测试时UI显示出现如图2所示问题
附(可能有用的其他信息):
相关UI组件碰撞盒略大以保证其被检测
相关UI组件的layer由UI改为default

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog