How do a Scan Graph while Runtime?

Hey I would like to scan my only active graph during runtime via code. But unfortunately, nothing happens.

private void bakeNavmesh()
    {
        foreach (NavGraph graph in AstarPath.active.graphs)
        {
            graph.Scan();
        }

        AstarPath.active.Scan();
    }

image

But then when I press the object on “Scan”. Then everything fits.
image

a other question how I can get access to the “Pathfinder” Script and all those settings?

Hi

That code should work, and it does the exact same thing as pressing the Scan button.
Are you sure you are calling the method after the level has been generated?

The pathfinder script is AstarPath.active.

yes I call it after everything is generated

    public void generate()
    {
        clearMap();
        startFillMap();
        bakeNavmesh();
        spawnPlayer();
    }

but I fixed it nevermind. Just made it to a Coroutine and said WaitForEndOfFrame() but that is just a workaround somehow.

image
But how can i change the widht and Nodesize via code?

You can use

// Get the first grid graph
var gridGraph = AstarPath.active.data.gridGraph;
gridGraph.SetDimensions(555, 555, 0.1);

// Scan the graph afterwards

See https://arongranberg.com/astar/docs/gridgraph.html#SetDimensions