how to make a drag selection in game

i’ve heard that some people just create an rectangle, and use “rect.Contains” to detect if the object is in the rectangle. however, the coordinate between rectangle and object is totally different. like, my target are mostly at the vector(0 0 0), and rectangle range is between 0-screen.hight&width. so how can i adjust them? or is there a better way to do this?
thank you.

use WorldToScreenPosition

Hi this has worked for me:

var rect:Rect;

rect.Set(Mathf.Min(selectionBoxStartPoint.x, Input.mousePosition.x), 
         Screen.height - Mathf.Max(selectionBoxStartPoint.y, Input.mousePosition.y),
         Mathf.Abs(selectionBoxStartPoint.x - Input.mousePosition.x),
         Mathf.Abs(selectionBoxStartPoint.y - Input.mousePosition.y));
var screenPos: Vector2 = Camera.main.WorldToScreenPoint(unit.transform.position);