GraphUpdateObject Mega Error Mess

`public void UpdateNavMesh(bool open)
{
if (open)
{
if (guo == null)
{
guo = new GraphUpdateObject(gameObject.GetComponentInChildren().bounds);
}

        guo.addPenalty = 1000;
        AstarPath.active.UpdateGraphs(guo);
    }
    if(open == false)
    {
        if(guo == null)
        {
            guo = new GraphUpdateObject(gameObject.GetComponentInChildren<Collider>().bounds);
        }
        guo.addPenalty = 0;

        AstarPath.active.UpdateGraphs(guo);
    }
}`

This is my simple method to update an area to be “avoid if possible”. However, it gives quite some interesting errors:

Some meshes were statically batched. These meshes can not be used for navmesh calculation due to technical constraints. UnityEngine.Debug:LogWarning(Object) Pathfinding.RecastGraph:GetSceneMeshes(Bounds) (at Assets/Code/3rd Party Plugins/AstarPathfindingProject/Generators/RecastGenerator.cs:692) Pathfinding.RecastGraph:CollectMeshes(List`1&, Bounds) (at Assets/Code/3rd Party Plugins/AstarPathfindingProject/Generators/RecastGenerator.cs:2215) Pathfinding.RecastGraph:UpdateAreaInit(GraphUpdateObject) (at Assets/Code/3rd Party Plugins/AstarPathfindingProject/Generators/RecastGenerator.cs:803) AstarPath:ProcessGraphUpdates(Boolean) (at Assets/Code/3rd Party Plugins/AstarPathfindingProject/Core/AstarPath.cs:1038) AstarPath:ProcessWorkItems(Boolean) (at Assets/Code/3rd Party Plugins/AstarPathfindingProject/Core/AstarPath.cs:816) AstarPath:PerformBlockingActions(Boolean, Boolean) (at Assets/Code/3rd Party Plugins/AstarPathfindingProject/Core/AstarPath.cs:722) AstarPath:Update() (at Assets/Code/3rd Party Plugins/AstarPathfindingProject/Core/AstarPath.cs:679)

CompareBaseObjectsInternal can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

Exception while updating graphs: System.ArgumentException: CompareBaseObjectsInternal can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene. Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function. at (wrapper managed-to-native) UnityEngine.Object:CompareBaseObjectsInternal (UnityEngine.Object,UnityEngine.Object) at UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) [0x00000] in C:\\BuildAgent\\work\\d63dfc6385190b60\\artifacts\\EditorGenerated\\UnityEngineObject.cs:49 at UnityEngine.Object.op_Inequality (UnityEngine.Object x, UnityEngine.Object y) [0x00000] in C:\\BuildAgent\\work\\d63dfc6385190b60\\artifacts\\EditorGenerated\\UnityEngineObject.cs:162 at Pathfinding.Voxels.Voxelize.FilterSmallRegions (System.UInt16[] reg, Int32 minRegionSize, Int32 maxRegions) [0x00006] in C:\\Users\\landon\\Documents\ectar\\DehrgadaNew\\Assets\\Code\\3rd Party Plugins\\AstarPathfindingProject\\Generators\\Utilities\\Voxels\\VoxelRegion.cs:1004 at Pathfinding.Voxels.Voxelize.BuildRegions () [0x00276] in C:\\Users\\landon\\Documents\ectar\\DehrgadaNew\\Assets\\Code\\3rd Party Plugins\\AstarPathfindingProject\\Generators\\Utilities\\Voxels\\VoxelRegion.cs:919 at Pathfinding.RecastGraph.BuildTileMesh (Pathfinding.Voxels.Voxelize vox, Int32 x, Int32 z) [0x001d5] in C:\\Users\\landon\\Documents\ectar\\DehrgadaNew\\Assets\\Code\\3rd Party Plugins\\AstarPathfindingProject\\Generators\\RecastGenerator.cs:1425 at Pathfinding.RecastGraph.UpdateArea (Pathfinding.GraphUpdateObject guo) [0x0025e] in C:\\Users\\landon\\Documents\ectar\\DehrgadaNew\\Assets\\Code\\3rd Party Plugins\\AstarPathfindingProject\\Generators\\RecastGenerator.cs:900 at AstarPath.ProcessGraphUpdatesAsync (System.Object _astar) [0x00074] in C:\\Users\\landon\\Documents\ectar\\DehrgadaNew\\Assets\\Code\\3rd Party Plugins\\AstarPathfindingProject\\Core\\AstarPath.cs:1147

The bounds are passing in correctly(found), and so is the active path. Not quite sure what’s going wrong. Disabling static batching doesn’t effect the problem, nor is the object marked as static.

Any ideas on whats wrong?

Thanks in advance.

Hi

The default setting for the GraphUpdateObject is to recalculate as much as possible (because people usually want that). For the recast graph, that means recalculating the whole tile(s) it touches. However since this happens during runtime, the graph cannot always get the mesh data if things are marked as ‘static’ in the scene due to Unity limitations.
Solution, disable recalculating the tiles
guo.updatePhysics = false;

Also, you might be interested in: http://arongranberg.com/astar/docs_dev/class_pathfinding_1_1_recast_mesh_obj.php#a5008f5aaa9ef50b1510e309dce9205d7

The CompareBaseObjectsInternal thing is however a bug, but that has been fixed in the latest beta. However if you do the change mentioned above you will not get this anymore.