Pathfinding.NavGraph.enabled feature

Hello,
I was wondering (since in rendering) we can click on the eye button on each graph to see or not see the graph. What if I wanted to also toggle weather or not a graph gets scanned during runtime by clicking on a toggle icon for that, so I wouldn’t have to delete and then re-create the graph itself whenever I want to use it again? An extra definition like Pathfinding.NavGraph.enabled would make it possible.

Here’s what I did so far… In the DrawMainArea() function in AstarPathEditor.cs, I added
`
bool[] enabled = new bool[script.graphs.Length];

	for (int i = 0; i < script.graphs.Length; i++) { 
	  enabled[i] = EditorGUILayout.Toggle ("Enable graph "+i,script.enabled[i]);
	  bool repaint = false;
	  if (script.enabled[i] != enabled[i]) {
	    script.enabled[i] = enabled[i];
	    repaint = true;
	  }
	  if (repaint) {
		RepaintSceneView ();
	  }
    }

`

The variable, enabled got added in AstarPath.cs as a bool[100]. I had to choose 100 because C# wouldn’t allow me to use a non-constant variable, otherwise, I would use graphs.Length. In AstarPathEditor.cs, I was able to use bool[] enabled = new bool[script.graphs.Length] for my enabled variable. Under it, is the code

for (int i = 0; i < script.graphs.Length; i++) { enabled[i] = EditorGUILayout.Toggle ("Enable graph "+i,script.enabled[i]); bool repaint = false; if (script.enabled[i] != enabled[i]) { script.enabled[i] = enabled[i]; repaint = true; } if (repaint) { RepaintSceneView (); } }

so it will show up in the Unity inspector. Then, I can select and de-select where it says, "Enable graph "+index depending on how many graphs there are. Here is the new code I added in the ScanLoop() function in AstarPath.cs.

`
for (int i=0;i<graphs.Length;i++) {
NavGraph graph = graphs[i];
if (enabled[i]) {

		if (OnGraphPreScan != null) {
			yield return new Progress (Mathfx.MapTo (0.05F,0.7F,(float)(i+0.5F)/(graphs.Length+1)),"Scanning graph "+(i+1)+" of "+graphs.Length+" - Pre processing");
			OnGraphPreScan (graph);
		}
					
		yield return new Progress (Mathfx.MapTo (0.05F,0.7F,(float)(i+1F)/(graphs.Length+1)),"Scanning graph "+(i+1)+" of "+graphs.Length);
		
		graph.Scan ();
					
		yield return new Progress (Mathfx.MapTo (0.05F,0.7F,(float)(i+1.1F)/(graphs.Length+1)),"Scanning graph "+(i+1)+" of "+graphs.Length+" - Assigning graph indices");
		if (graph.nodes != null) {
			for (int j=0;j<graph.nodes.Length;j++) {
				if (graph.nodes[j] != null) 
					graph.nodes[j].graphIndex = i;
			}
		}
		
		if (OnGraphPostScan != null) {
			yield return new Progress (Mathfx.MapTo (0.05F,0.7F,(float)(i+1.5F)/(graphs.Length+1)),"Scanning graph "+(i+1)+" of "+graphs.Length+" - Post processing");
			OnGraphPostScan (graph);
		}
		} else {
		  for (int j = 0; j < graph.nodes.Length; j++) { 
			graph.nodes[j].position.x = 10000;
			graph.nodes[j].position.y = 10000;
			graph.nodes[j].position.z = 10000;
		  }
	    }
	}

`

I had to pick Vector3(10000,10000,10000) because if I try and make all the nodes null or equal to new Node[1], I have problems.

Okay, reasonable request. I will add that to the todo list.