public bool IsVisible(Bounds bounds, Camera camera) { // 得到摄像机的六个面 Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera); // 判断边框bound是否在六个面内 return GeometryUtility.TestPlanesAABB(planes, bounds); } 需要给游戏对象添加Collider if (GameDatabase.Instance.IsVisible(GetComponent().bounds, Camera.main)) { Debug.Log("可见"); } else { //Debug.Log("不可见"); }
Unity如何判断游戏对象是否在屏幕内
最新推荐文章于 2022-09-20 16:47:43 发布