Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
0
Question by Silverlode · Apr 13, 2017 at 12:42 PM · navmeshnavigationbakeruntime-generation

Where is 'min region area' setting when baking navmesh at runtime?

When using NavMesh static baking, I got the results I wanted, only when I set "Min Region Area" in the Bake tab of the Navigation window, to 0.05.

I can't find how to control that setting when I bake my NavMesh at run time (Unity 5.6) through the NavMeshBuilder class - as a result, my NavNesh is broken.

Can someone point me to how I control this setting or equivalent, at runtime?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by MeTheFlea · Apr 21, 2017 at 09:18 AM

Hey, I was looking for something similar and could not find a public API for it. However, if you examine the decompiled UnityEngine.dll you can see that there is a private float m_MinRegionArea; which means that we can set that value using reflection.

Note that there is no guarantee that this will keep working in later versions of Unity, but for now (Unity 5.6.0f3) this is working for me:

 NavMeshBuildSettings settings = NavMesh.GetSettingsByIndex( 0 ); // or whatever
   
 var prop = typeof( NavMeshBuildSettings ).GetField( "m_MinRegionArea", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
 object boxedSettings = settings;
 prop.SetValue( boxedSettings, [YOUR_VALUE] );
 
 settings = (NavMeshBuildSettings)boxedSettings;

Take a look at this stack overflow question if you are wondering why it's required to do object boxedSettings = settings;

Comment
Add comment · Show 1 · 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 The-Wizzard-OZ · Apr 22, 2020 at 10:30 AM 0
Share

Hello, I am trying to change the "m_VoxelSize" and for that, I know I need to change "m_OverrideVoxelSize" to true. However, I don't know how to do that. I used your method to change "m_VoxelSize". However, nothing happened when I run in Unity. I know something must happen if I change the voxelSize to 0.5f because when I did manually it acts as I desire but because I am procedurally generating my world I need it to procedurally generate the Nav$$anonymous$$esh with a specific voxelSize I want it to be. However, it's my second day on the internet but I couldn't find an explanation for how to change the voxel size through the script on the new version of the Unity (2019.3.10f1). Normally people. get around this by creating prefabs with premade Nav$$anonymous$$esh on them, however, in my case, this is not an option since I am generating a voxel terrain made out of (1,1,1) scale cubes. Hence I need to find a way to change the voxelSize Somehow.

I would really appreciate if you can find a solution.

 void UpdateNav$$anonymous$$esh(bool asyncUpdate = false)
     {
         Nav$$anonymous$$eshSourceTag.Collect(ref m_Sources);
         var defaultBuildSettings = Nav$$anonymous$$esh.GetSettingsByID(0);
         var vox = typeof( Nav$$anonymous$$eshBuildSettings ).GetField("m_OverrideVoxelSize");
         var prop = typeof( Nav$$anonymous$$eshBuildSettings ).GetField( "m_VoxelSize", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance );
         object boxedSettings = defaultBuildSettings;
         vox.SetValue(boxedSettings, true);
         prop.SetValue(boxedSettings, 0.5f);
         defaultBuildSettings = (Nav$$anonymous$$eshBuildSettings)boxedSettings;
         var bounds = QuantizedBounds();
 
         if (asyncUpdate)
             m_Operation = Nav$$anonymous$$eshBuilder.UpdateNav$$anonymous$$eshDataAsync(m_Nav$$anonymous$$esh, defaultBuildSettings, m_Sources, bounds);
         else
             Nav$$anonymous$$eshBuilder.UpdateNav$$anonymous$$eshData(m_Nav$$anonymous$$esh, defaultBuildSettings, m_Sources, bounds);
     }

Above is the part I am trying to reach to the "m_VoxelSize" in UnityEngine.AI$$anonymous$$odule.dll I am using the LocalNav$$anonymous$$eshBuilder script from https://github.com/Unity-Technologies/Nav$$anonymous$$eshComponents. I just edited. a bit to also have a Nav$$anonymous$$esh with a specific VoxelSize. However, I got no success.

Thank you in advance!

avatar image
0

Answer by Silverlode · Apr 14, 2017 at 05:47 AM

Well, I haven't found this setting yet, nor do I understand how that settings translates to the runtime system, but it appears it wasn't that setting that was my only issue - the objects used to create the navmesh were at an angle, but I didn't realized this with my orthogonal view. Correcting the angle gave me the navmesh I wanted - but I'm still curious how to control the threshold for region size to be culled?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Bake navmesh after changing the size 0 Answers

Multiple Navmesh Bakes 2 Answers

Need help with navmesh,Already bake Navmesh but still got error 1 Answer

GameObject's Navigation Area from script 0 Answers

NavMesh baking 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