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?

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;

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?