GenerateNodes Giving Error

I’m getting the exception:

Trying to initialize a node when it is not safe to initialize any nodes. Must be done during a graph update

When I try to run GenerateNodes on a newly created NavMeshGraph. Here is my code:

Pathfinding.NavGraph graph = AstarPath.active.astarData.CreateGraph(typeof(Pathfinding.NavMeshGraph));
Pathfinding.NavMeshGraph navGraph = (Pathfinding.NavMeshGraph)graph;

navGraph.GenerateNodes(navVerts.ToArray(), navTris.ToArray(), out origNavVerts, out origNavTris);
AstarPath.active.astarData.AddGraph(navGraph);

Not sure how I can cause this to run “during a graph update”, so any help would be appreciated.

-Sean

Answered it myself. Not supposed to call GenerateNodes directly. Instead you build a Mesh and set the NavGraph’s sourceMesh to that mesh, then scan the graph and it generates the nodes for you.