void OnDrawGizmos()
{
Gizmos.color = Color.green;
if (theCamera == null)
theCamera = GetComponent<Camera>();
Gizmos.matrix = Matrix4x4.TRS(theCamera.transform.position, theCamera.transform.rotation, Vector3.one);
Gizmos.DrawFrustum(Vector3.zero, theCamera.fieldOfView, theCamera.farClipPlane, theCamera.nearClipPlane, theCamera.aspect);
}
以上代码为编辑器中画出透视相机的视景体,方便调试。