OK, this may get a little complicated.
first, have a look at this documentation:
Basically this uses a bunch of planes and calculates if any portion of a bounding box is in that plane.
You can make planes by using points…
OK, so in order to get points, you will need to get 4 rays. I would use the x and y position from the screen and add an extents to it. Say 16 pixels. Next, take each of those rays and get two points from them which correspond to Camera.nearClipPlane and farClipPlane. Now, you will have 8 points. Take two points from each ray, and match it up with 1 point from the next. (4 times over, and that will give you 4 of the 6 planes you need. The other 2 come from the low and high values of the rays.
Plane[] GetProjection(int x, int y, int extents){
List<Vector3[]> r = new List<Vector3[]> ();
r.Add(GetProjection (x - extents, y - extents));
r.Add(GetProjection (x + extents, y - extents));
r.Add(GetProjection (x - extents, y + extents));
r.Add(GetProjection (x + extents, y + extents));
Plane[] p = new Plane[6];
p [0] = new Plane (r [0] [0], r [0] [1], r [1] [0]); // top plane
p [1] = new Plane (r [1] [0], r [1] [1], r [3] [0]); // right plane
p [0] = new Plane (r [3] [0], r [3] [1], r [2] [0]); // bottom plane
p [0] = new Plane (r [2] [0], r [2] [1], r [0] [0]); // left plane
p [0] = new Plane (r [0] [0], r [1] [0], r [2] [0]); // near clip plane
p [0] = new Plane (r [0] [1], r [1] [1], r [2] [1]); // far clip plane
return p;
}
Vector3[] GetProjection(int x, int y){
Vector3[] v = new Vector3[2];
Ray ray = Camera.main.ScreenPointToRay (new Vector3 (x, y, 0));
v [0] = ray.GetPoint (Camera.main.nearClipPlane);
v [1] = ray.GetPoint (Camera.main.farClipPlane);
return v;
}
Now, with those planes, you can use this:
to test if anything is in them. Then test them for nearest point to the camera or however you want to test them.