Skip to content

Instantly share code, notes, and snippets.

@AngryAnt
Created August 18, 2011 12:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AngryAnt/1153991 to your computer and use it in GitHub Desktop.
Save AngryAnt/1153991 to your computer and use it in GitHub Desktop.
Getting the total rendering bounds of a hierarchy of renderers.
private Bounds bounds;
void Start ()
{
bounds = new Bounds (transform.position, Vector3.one);
Renderer[] renderers = GetComponentsInChildren<Renderer> ();
foreach (Renderer renderer in renderers)
{
bounds.Encapsulate (renderer.bounds);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment