public static bool ScreenPointToWorldPointInRectangle(RectTransform rect, Vector2 screenPoint, Camera cam, out Vector3 worldPoint)
{
worldPoint = (Vector3)Vector2.zero;
Ray ray = RectTransformUtility.ScreenPointToRay(cam, screenPoint);
float enter;
if (!new Plane(rect.rotation * Vector3.back, rect.position).Raycast(ray, out enter))
{
return(false);
}
worldPoint = ray.GetPoint(enter);
return(true);
}