// Calculate the bounds for all selected brushes, respecting the current pivotRotation mode to produce // bounds aligned to the first selected brush in Local mode, or bounds aligned to the absolute grid in Global // mode. public Bounds GetBounds() { Bounds bounds; if (Tools.pivotRotation == PivotRotation.Local) { bounds = primaryTargetBrush.GetBounds(); for (int i = 0; i < targetBrushes.Length; i++) { if (targetBrushes[i] != primaryTargetBrush) { bounds.Encapsulate(targetBrushes[i].GetBoundsLocalTo(primaryTargetBrush.transform)); } } } else // Absolute/Global { bounds = primaryTargetBrush.GetBoundsTransformed(); for (int i = 0; i < targetBrushes.Length; i++) { if (targetBrushes[i] != primaryTargetBrush) { bounds.Encapsulate(targetBrushes[i].GetBoundsTransformed()); } } } return(bounds); }
/// <summary> /// Resizes the brush so that it's local bounds match the specified extents /// </summary> /// <param name="brush">The brush to be resized</param> /// <param name="rescaleValue">The extents to match</param> public static void Resize(PrimitiveBrush brush, Vector3 resizeValue) { Bounds bounds = brush.GetBounds(); // Calculate the rescale vector required to change the bounds to the resize vector Vector3 rescaleVector3 = resizeValue.Divide(bounds.size); Scale(brush, rescaleVector3); }