0

我想通过不显示不在相机字段中的游戏对象来优化我的手机游戏。我不能进行遮挡剔除,因为这些游戏对象是实例化的,而不是静态的。

所以我用

void OnBecameInvisible(){  Renderer.enabled = false; }

void OnBecameVisible(){  Renderer.enabled = true; }

它有效,但有时,物体仍然不可见。

我尝试使用:

void Update()
{
    if (m_Renderer.isVisible)
    {
        m_Renderer.enabled = true;
        Debug.Log("show");
    }
    else m_Renderer.enabled = false; Debug.Log("not show");
}

但是性能下降得很厉害。

我怎么能解决这个问题?

谢谢你。问候。

4

1 回答 1

2

默认情况下, Unity 会自动使用Frustum Culling并且不会渲染相机没有看到的内容。因此这是自动实现的

于 2019-03-04T20:30:53.730 回答