【发布时间】:2017-10-19 09:40:01
【问题描述】:
我四处寻找不同的解决方案,以使对象在 VR 中离开特定摄像机视口时消失。
我最终使用 GeometryUtility 使用以下解决方案:
//Create camera planes
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
//Check if object renderer is in camera view
if (!GeometryUtility.TestPlanesAABB(planes, GetComponent<Renderer>().bounds))
{
//Condition waiting for 2nd object to spawn (To avoid object 1 doesn't disappear instantly)
if (objectCondition.activeSelf)
{
//Deactivate object
gameObject.SetActive(false);
}
}
但是,这会导致对象在离开视口之前消失(大约在中间,而不是一直)。我是在执行这个错误,还是只是一个 VR 问题?
【问题讨论】:
-
你设置正确了吗?该脚本在您当前要禁用的游戏对象中?这个游戏对象有碰撞器吗?