22 lines
579 B
C#
22 lines
579 B
C#
using UnityEngine;
|
|
|
|
namespace GraphicsCat
|
|
{
|
|
public static class BoundsUtils
|
|
{
|
|
public static Bounds GetHierarchyBounds(GameObject root)
|
|
{
|
|
if (root == null) return new Bounds();
|
|
|
|
var renderers = root.GetComponentsInChildren<Renderer>(true);
|
|
if (renderers.Length == 0) return new Bounds();
|
|
|
|
Bounds combinedBounds = renderers[0].bounds;
|
|
for (int i = 1; i < renderers.Length; i++)
|
|
combinedBounds.Encapsulate(renderers[i].bounds);
|
|
|
|
return combinedBounds;
|
|
}
|
|
}
|
|
}
|