- Home /
Found link to a similar problem.
Encapsulate Bounds Problem [SOLVED]
Hi,
I am trying to get the total dimensions for an object and all it's children. I am very close but can't quite seem to get over the last hurdle.
I am able to iterate through the children and see all objects in the array.
I am also able to see the individual children Bounds sizes.
But I cannot get it to give me the total dimensions of them all. From what I can tell I need to encapsulate them, but my total encapsulation only gives me the bounds size for the parent object.
[Edit] Problem solved as I eventually found this post (Eric5h5 to the rescue . . . again!):
http://answers.unity3d.com/questions/17968/finding-the-bounds-of-a-grouped-model.html
Thanks
Paul
Answer by zyzyx · Dec 07, 2012 at 03:00 PM
Since Encapsulate only encapsulates a point (Vector3) in space r.bounds seems not to be a valid argument.
Wrong, it encapsulates with a point, or bounds - check the doco page
.
You could try (not testet):
for(r in renderers){
totalBounds.Encapsulate(r.min);
totalBounds.Encapsulate(r.max);
}
Thanks zyzyx , that never worked for me but I found exactly what I was looking for here:
http://answers.unity3d.com/questions/17968/finding-the-bounds-of-a-grouped-model.html
Follow this Question
Related Questions
How does Bounds.Encapsulate() work? 2 Answers
Calculating BoxCollider bounds and center in runtime 1 Answer
Dynamically creating a box collider for an object with multiple, rotated, and scaled mesh renderers 0 Answers
Are my bounds right world position in this case ? 1 Answer
True scale of a visible GameObject with many childs 1 Answer