Changing GridGraph data at runtime problems

After generating my procedural map which could be any size (let’s assume 200x200), I want to change the dimensions of the GridGraph to match.

I’ve searched through the entire GridGraph documentations but there are some problems which I don’t know how to solve. Here’s how I do it:

_graphData = AstarPath.active.data;
_gridGraph = _graphData.graphs[0] as GridGraph;

_gridGraph.SetDimensions(Map.Instance.Size.x, Map.Instance.Size.y, 1);
AstarPath.active.Scan();

However, this somehow overrides some settings that I initially setup for the graph which I always want to be the same, for example, the 2D option needs to be checked, and the Center of the graph needs to be Bottom Left and set to (0,0,0) which I have no idea how to change through code.

Here’s what I start with and what I want to achieve (I only really want to change the width and depth):
Screenshot_1

But here’s what I end up with after calling the code above:
Screenshot_2

I’ve tried using RelocateNodes but that either completely messes up the rotation or unchecks the 2D option.

So - my question is:
How can I just change the width and depth and leave all other options the same AND if need be later, how can I change the Center pivot so it says Bottom Left, like in the inspector, but through code?

Hi

Internally the graph is represented using a center point + some dimensions. The origin utility thing that allows you to specify a corner of the graph is purely an editor helper.
So if you want to set the dimensions and the position I would recommend that you set the _gridGraph.center field too. See this page for more details: https://arongranberg.com/astar/docs/runtimegraphs.html

The 2D toggle is internally set when the rotation of the graph is aligned with the 2D plane.
You can make it 2D by aligning it with that plane, for example by setting the rotation to (-90, 270, 90).
The SetDimensions call doesn’t modify the rotation though, so it shouldn’t uncheck the 2D toggle.