// This returns element.Bounds2D re-centered at origin, ie without the local // translation of element. Child elements should be laid out relative to this box. public static FixedBoxModelElement ContentBounds(IBoxModelElement element, float fPadding) { AxisAlignedBox2f bounds = element.Bounds2D; bounds.Translate(-bounds.Center); return(new FixedBoxModelElement(bounds)); }
public static AxisAlignedBox2f LocalBounds(IBoxModelElement element) { AxisAlignedBox2f bounds = element.Bounds2D; bounds.Translate(-bounds.Center); return(bounds); }
public static AxisAlignedBox2f GetBounds2D(RectTransform rectT) { AxisAlignedBox2f box = rectT.rect; box.Translate(rectT.anchoredPosition); return(box); }
/* * RectTransform manipulation */ public static AxisAlignedBox2f GetBounds2D(GameObject go) { RectTransform rectT = go.GetComponent <RectTransform>(); AxisAlignedBox2f box = rectT.rect; box.Translate(rectT.anchoredPosition); return(box); }
// This returns ContentBounds with a padding offset public static AxisAlignedBox2f PaddedContentBounds(IBoxModelElement element, float fPadding) { AxisAlignedBox2f bounds = element.Bounds2D; bounds.Translate(-bounds.Center); bounds.Contract(fPadding); return(bounds); }