Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by unity.editor · Jul 30, 2012 at 10:17 AM · rendererbounds

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.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
10
Best Answer

Answer by Bunny83 · Jul 30, 2012 at 10:32 AM

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.

Comment
Add comment · Show 12 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unity.editor · Jul 30, 2012 at 10:42 AM 0
Share

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

avatar image Bunny83 · Jul 30, 2012 at 01:35 PM 1
Share

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

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

avatar image Bunny83 · Jul 31, 2012 at 01:21 PM 5
Share

Again, Renderer.bounds is deter$$anonymous$$ed 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. $$anonymous$$esh.bounds is a local AABB and Renderer.bounds a worldspace AABB.

avatar image Bunny83 · Aug 01, 2012 at 01:55 AM 1
Share

Don't give up. I've just written this little helper script(Show$$anonymous$$eshBounds.cs) which can visualize the $$anonymous$$esh.bounds and the Renderer.bounds as transparent cubes (mesh.bounds == the red cube, renderer.bounds == green cube).

Just attach the script to your model (whereever your meshfilter or skinnedmeshrenderer is)

avatar image Bunny83 · Aug 01, 2012 at 03:03 AM 1
Share

I just found a bug in my old script(Show$$anonymous$$eshBounds.cs) ;) I've fixed it.

I've also written another little script(Set$$anonymous$$eshBounds.cs) which allows you to set the bounds of a mesh at runtime. You can tweak the values in the inspector. Together with the visualization script you should be able to fix your bounds problems ;)

Show more comments
avatar image
1

Answer by Kryptos · Jul 30, 2012 at 10:37 AM

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.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image unity.editor · Jul 30, 2012 at 10:41 AM 0
Share

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).

avatar image unity.editor · Jul 30, 2012 at 10:46 AM 0
Share

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.

avatar image
0
Wiki

Answer by ProbePLayer · Aug 15, 2013 at 10:20 PM

as everyone else stated, modifying Mesh.bounds would probably be your solution. my addition to this would be in case the bounds.expand function doesn't seem to work, modify it through manual expansion, like this:

         //expand the bounding box so that it keeps up with the mesh
         //otherwise the mesh wont show when the mesh is in camera frustum and the bounds are not
         Bounds bounds = new Bounds(mesh.bounds.center, mesh.bounds.size+new Vector3(waveSpeed,waveSpeed,waveSpeed));
         mesh.bounds = bounds;
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Renderer.bounds.extenct.x; cant find bounds 0 Answers

How do I check if an object is completely visible? 4 Answers

Bounds larger than expected 1 Answer

"Mesh 'NormalCurveRendererMesh': abnormal mesh bounds..." error appears on editor... 0 Answers

Text with fixed size in viewport 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges