public override void updateBoundRect()
{
_isBoundRectDirty = false;
Vector2 minPos = new Vector2(999999,999999);
Vector2 maxPos = new Vector2(-999999,-999999);
// loop though children to get the bound area of children
foreach(DisplayObject child in _childList){
Rect childBoundRect = _transform.getBoundRect(child.boundRect);
if(childBoundRect.x < minPos.x){
minPos.x = childBoundRect.x;
}
if(childBoundRect.x+childBoundRect.width > maxPos.x){
maxPos.x = childBoundRect.x+childBoundRect.width;
}
if(childBoundRect.y < minPos.y){
minPos.y = childBoundRect.y;
}
if(childBoundRect.y+childBoundRect.height > maxPos.y){
maxPos.y = childBoundRect.y+childBoundRect.height;
}
}
if(maxPos.x>minPos.x && maxPos.y>minPos.y){
_originalWidth = maxPos.x-minPos.x;
_originalHeight = maxPos.y-minPos.y;
// get boundRect, boundRect is related with it's parent
_boundRect.x = minPos.x;
_boundRect.y = minPos.y;
_boundRect.width = maxPos.x-minPos.x;
_boundRect.height = maxPos.y-minPos.y;
_width = _boundRect.width;
_height = _boundRect.height;
}else{
_boundRect.x = 0;
_boundRect.y = 0;
_boundRect.width = 0;
_boundRect.height = 0;
_width = 0;
_height = 0;
}
_boundRectInTree = _boundRect;
//Debug.Log(id+ "updateBoundRect" + _boundRect);
}