using System.Collections; using System.Collections.Generic; using UnityEngine; public static class GameObjectExtensions { /// /// Retourns the bounds of all colliders in a gameobject /// /// Gameobject to get bounds of /// Bounds of gameobject public static Bounds GetBounds(this GameObject gameObject) { Bounds bounds = new Bounds(gameObject.transform.position, Vector3.zero); Collider[] colliders = gameObject.GetComponentsInChildren(); foreach (Collider col in colliders) { bounds.Encapsulate(col.bounds); } return bounds; } }