if your 2D game is laying on the XY plane for example, all you have to do is to determine 4 points in Global/WorldSpace. These points will be the 4 corners of the red rectangle and their coordinates will be formed with:
- max X coordinate over all the childrens
- max Y coordinate over all the childrens
- min X coordinate over all the childrens
- min Y coordinate over all the childrens
When calculating the local edges coordinates for your children you can use their bounding box or bounding circle (center position +/- radius). All you have to do is to maintain 4 variables in which you save max and min x/y coordinates you found parsing all your children objects
Pseudocode will be something like:
foreach( child in parent )
{
if ( child.min_x < min_x ) min_x = child.min_x;
if ( child.min_y < min_y ) min_y = child.min_y;
if ( child.max_x > max_x ) max_x = child.max_x;
if ( child.max_y > max_y ) max_y = child.max_y;
}
so now you'll have these 4 values let's form the 4 points (pseudo code):
top_left = Point2D(min_x, max_y);
top_right = Point2D(max_x, max_y);
bottom_right = Point2D(max_x, min_y);
bottom_left = Point2D(min_x, min_y);
So now that you have the corners of the rectangle, calculating the dimension is straight forward because you can consider 2D Points as 2D Vectors and calculate their distance to determine the edges of the red box. So you can simple calculate a difference between the points or use the Unity built-in function Vector2.Distance like so:
float BaseOfRedBox = Vector2.Distance(bottom_right, bottom_left); // the base
float HeightOfRedBox = Vector2.Distance(bottom_right, top_right); // the height
float AreaOfRedBox = BaseOfRedBox * HeightOfRedBox; // the Area
You can do more stuff considering the 2D Points as vectors and determine 2D Normals and so...
All the calculation is made in WorldSpace if you need to transform the points back to screen space just use the Unity function camera.WorldToScreenPoint(...) where camera is your main orthographic camera.