- Home /
Question by
Gorov · Jul 29, 2012 at 01:04 PM ·
boundsencapsulation
Check if bounds is Encapsulated in another bounds
Hi,
I need to check if a bounds is encapsulated in another bounds function.
Thanks in advance!
Comment
Answer by ScroodgeM · Jul 30, 2012 at 08:06 PM
static bool BoundsIsEncapsulated(Bounds Encapsulator, Bounds Encapsulating) { return Encapsulator.Contains(Encapsulating.min) && Encapsulator.Contains(Encapsulating.max); }
Answer by kittikun · Mar 12, 2014 at 06:33 AM
To extend the answer, you can extend the Bounds class to add a ContainBounds method
public static class Boundsxtension
{
public static bool ContainBounds(this Bounds bounds, Bounds target)
{
return bounds.Contains(target.min) && bounds.Contains(target.max);
}
}