您的位置:首页 > 移动开发 > Unity3D

unity 检测物体是否在相机视野范围内

2017-02-05 19:48 399 查看
脚本挂在摄像机要显示的对象上

前提:该对象有 render 组件

public class visibleTT : MonoBehaviour
{
public bool isRendering = false;
public float lastTime = 0;

public float curTime = 0;

void Update()
{

if (lastTime != curTime)
{
isRendering = true;
Debug.Log("In View");
}

else
{ isRendering = false;
Debug.Log("Not In View");
}

lastTime = curTime;

}

void OnWillRenderObject()
{

curTime = Time.time;

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  unity