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