x


Renderer Bounds

how would I set a renderers bounds (center and extents) in script? the inspector provides access to it, but I know its read-only when I try to do the same in a script. Thanks.

more ▼

asked Jul 30 '12 at 10:17 AM

unity.editor gravatar image

unity.editor
37 3 4 6

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Renderer.bounds just tells you the bounds of the renderer. This depends on the object it is rendering. You can't set the bounds, why would you? The bounds are a result of the objects position / scale / rotation.

more ▼

answered Jul 30 '12 at 10:32 AM

Bunny83 gravatar image

Bunny83
46.9k 12 50 210

there are some issues with the model/rig that require manual adjustments (and unfortunately fixing the rig is not an option)

Jul 30 '12 at 10:42 AM unity.editor

Well, if you want to set the bounds manually, you have to set

Mesh.bounds, not Renderer.bounds. The renderer is just a component which renders the mesh. The Mesh represents the actual data.

Jul 30 '12 at 01:35 PM Bunny83

tried that to no avail, thanks for the suggestion!

Jul 31 '12 at 02:22 AM unity.editor

I just tried it myself and it works like expected... When i insert a cube and change the mesh bounds, the isVisisble flage is changing like expected.

What kind of problems do you have? Usually the bounds are calculated correctly for any kind of mesh, so where or how do you experience problems?

Jul 31 '12 at 02:44 AM Bunny83

Again, Renderer.bounds is determined at runtime. It's not stored anywhere. It represents the axis-aligned-bounding-box (AABB) that encloses the rotated mesh.bounds. mesh.bound can be changed manually, but Renderer.bound is always an AABB, so when the object is rotated, it will be larger.

How does your object look like? If the mesh is already rotated in local space, the mesh.bounds will already be too large. The bounds can't be rotated to match your object shape. Mesh.bounds is a local AABB and Renderer.bounds a worldspace AABB.

Jul 31 '12 at 01:21 PM Bunny83
(comments are locked)
10|3000 characters needed characters left

If you are creating a mesh a runtime, then you might be looking for Mesh.RecalculateBounds. Otherwise, as @Bunny83 said, there is not need to set the bounds yourself.

more ▼

answered Jul 30 '12 at 10:37 AM

Kryptos gravatar image

Kryptos
7.2k 5 33

thanks for the replies, but there are issues with the model and rig I received leading to my need to do some manual adjustments. I was hoping to automate this, but I guess that isn't possible (and neither if fixing the rig).

Jul 30 '12 at 10:41 AM unity.editor

I tried that but since the model/rig are at fault, it just recalculates the same bad bounds and fixing the rig is not currently an option.

Jul 30 '12 at 10:46 AM unity.editor
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x281
x101

asked: Jul 30 '12 at 10:17 AM

Seen: 1084 times

Last Updated: Aug 01 '12 at 06:57 AM