Unity如何判断游戏对象是否在屏幕内

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("不可见"); }

你可能感兴趣的:(Unity3D,C#)