A物体有CameraB渲染,首先将A物体世界坐标转换为屏幕坐标,再由屏幕坐标的x与Screen.width做比较,如果x<Screen.width则在屏幕内,否则在屏幕外。
Vector3 screen3dPos = CameraB.WorldToScreenPoint(enemy.transform.position);
if (screen3dPos.x > Screen.width)
{
Debug.Log("out of screen");
}else{
Debug.Log("in screen");
}
本文出自 “每天进步一点点” 博客,请务必保留此出处http://568464209.blog.51cto.com/7726521/1861650
原文地址:http://568464209.blog.51cto.com/7726521/1861650