Grid graph size changes without changing node size

Hey all

Im trying to set up a grid graph that resizes itself to the size of a randomly generated level and then re-scans the area for walkable paths. I am coming slightly unstuck with as im able to resize and rescan, however nmy node size is changing which means certain areas that should be accessible are no longer accessible.

Basically i want my nodesize to stay at 0.5f no matter how big the width and depth of the area is. Currently as the area increase the numbers auto adjust either width/height/nodesize based on editing one of the other values (this includes in editor at runtime when im manually inputting the values)

My original thought was that it was to do the the padlock simbol in the grid inspector however toggling this led to no further developments in these values.

Thanks for any help



So you are saying that you are modifying these values using script?
Could you post the code that you use to do that?

yes i am modifing them through script. This was what i orginally tried

    GridGraph gGraph =;
    if (gGraph != null)
        gGraph.width = Mathf.CeilToInt(GetSceneBounds.instance.b.size.x / gGraph.nodeSize);
        gGraph.depth = Mathf.CeilToInt(GetSceneBounds.instance.b.size.z / gGraph.nodeSize);
        gGraph.UpdateSizeFromWidthDepth(); =;

then tried doing it this way
var guo = new GraphUpdateObject(GetSceneBounds.instance.b); (guo);

both ways to modify the size of the grid (even though it changes it to the wrong size) but they all modify the size of the nodesize as well. Really all i want to do is set the width and height to the values of GetSceneBounds.instance.b and then rescan.


That should not modify the node size unless you are trying to create a graph larger than 1024 nodes (along some direction). I clamp the values at 1024 to avoid users freezing the unity editor by mistake because they try to generate/visualize a very large graph. I do not recommend graphs larger than 1024*1024, but you can disable that limit if necessary.

That may be why then, the level that is first noticed this on was a level that is slightly larger than 1024*1024.

If i wanted to go about disabling this how would i go about do it (at least in the short term until i can stream the level better)

Check GridGenerator.cs -> GenerateMatrix method. There are two lines that look like this

// Clamp the nodeSize so that the graph is never larger than 1024*1024
nodeSize = Mathf.Clamp(nodeSize, newSize.x/1024F, Mathf.Infinity);
nodeSize = Mathf.Clamp(nodeSize, newSize.y/1024F, Mathf.Infinity);

However I warn you that a graph larger than 1024*1024 will use a very large amount of resources. That’s 1 million nodes, so it is not going to use a trivial amount of RAM.
You probably want to make sure that ‘Show Graphs’ is disabled to avoid bringing the Unity Editor to a crawl due to the gizmo drawing.

Thanks for the help, ill modify those lines and hopefully that should fix the problem.

I am working on a way to stream the level more efficiently and not have the nav mesh that big but in the short term for testing. Thanks for the advice on disableing the show Graphs option, sure that will come in handy to not slow my computer down and Thanks for the help with this