Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: hesoul on January 03, 2014, 07:38:28 AM

Title: Raycast distance of UICamera
Post by: hesoul on January 03, 2014, 07:38:28 AM
The distance is calculated:
float dist = (cam.rangeDistance > 0f) ? cam.rangeDistance : currentCamera.farClipPlane - currentCamera.nearClipPlane;
when camera is OrthoGraphic there was no problem,but in 3D camare,whether this should be changed?
float dist = 0;
if (cam.rangeDistance > 0f) dist = cam.rangeDistance;
else
{
    dist = currentCamera.farClipPlane - currentCamera.nearClipPlane;
    if (!currentCamera.isOrthoGraphic)
        dist /= Mathf.Cos(Vector3.Angle(currentCamera.transform.forward, ray.direction) * 0.01745f);
}
Title: Re: Raycast distance of UICamera
Post by: ArenMook on January 03, 2014, 10:05:20 AM
This means you may hit invisible objects. If you want extended range, set the raycast range on the UICamera.
Title: Re: Raycast distance of UICamera
Post by: hesoul on January 03, 2014, 10:31:40 AM
but 4 corners may not be hit,as shown in the figure,the red area can not be hit
Title: Re: Raycast distance of UICamera
Post by: ArenMook on January 03, 2014, 11:03:00 AM
Yup, I know. But in your case objects behind the visible plane will be hit, which is just as wrong. There is no perfect fix here.