Unity 提供了可以根据不同的layer来设置不用的view distance,所以我们可以实现将物体进行分成,大物体层设置的可视距离大些,而小物体层可设置的小些。
using UnityEngine;
using System.Collections;
public class CamerLayerCullSpherical : MonoBehaviour
{
// Use this for initialization
public float[] layerCullSpherical;
void Start ()
{
camera.layerCullSpherical = true;
if (layerCullSpherical != null && layerCullSpherical.Length > 0)
{
camera.layerCullDistances = layerCullSpherical;
}
}
void Update()
{
#if UNITY_EDITOR
if (layerCullSpherical != null && layerCullSpherical.Length > 0)
{
//for (int idx = 0; idx < layerCullSpherical.Length; ++idx)
//{
//}
camera.layerCullDistances = layerCullSpherical;
}
}
#endif
}