Navmesh Cut does not work second graph

Navmesh Cut works normally in the first graph.
However, if you create a second graph, it will only work on the first Graph.
Is there a way?

Hi

Currently this is not possible out of the box. However you can create multiple TileHandlerHelper components from a script to do this:

var graphs = AstarPath.active.graphs;
for (int i = 0; i < graphs.Length; i++) {
     if (graphs[i] is NavmeshBase) {
         var handler = new TileHandler(graphs[i] as NavmeshBase);
         gameObject.AddComponent<TileHandlerHelper>().UseSpecifiedHandler(handler);
         handler.CreateTileTypesFromGraph();
     }
}

Sorry, can you explain more?
Should I write a new script and write that script?

When I create a new script and start your script, an error message is printed

There should only be one TileHandlerHelper per scene. Destroying.
UnityEngine.Debug:LogError(Object)
Pathfinding.TileHandlerHelper:Start() (at Assets/AstarPathfindingProject/Navmesh/TileHandlerHelper.cs:78)

This is my script.

using UnityEngine;
using System.Collections.Generic;
using Pathfinding.Util;

namespace Pathfinding
{
public class MultipleTileHelper : MonoBehaviour
{

	// Use this for initialization
	void Start ()
	{
		var graphs = AstarPath.active.graphs;
		for (int i = 0; i < graphs.Length; i++) {
			if (graphs [i] is NavmeshBase) {
				var handler = new TileHandler (graphs [i] as NavmeshBase);
				gameObject.AddComponent<TileHandlerHelper> ().UseSpecifiedHandler (handler);
				handler.CreateTileTypesFromGraph ();
			}
		}
	}

}

}

Or should I modify the TileHanderHelper script?
This is a very important issue for my project.
Please explain in detail.

Thank you for your help.

Ah. Right. You have done everything correctly as far as I can see. However I remembered that you also need to remove a piece of code from the TileHandlerHelper script. Find that script and look in the Start method of it. Remove this code:

if (FindObjectsOfType(typeof(TileHandlerHelper)).Length > 1) {
	Debug.LogError("There should only be one TileHandlerHelper per scene. Destroying.");
	Destroy(this);
	return;
}

For future readers: version 4.1.19 (currently a beta version available here: https://www.arongranberg.com/astar/download) now has support for navmesh cutting on all graphs out of the box, the TileHandlerHelper component isn’t even necessary anymore.

@aron_granberg
Is it possible (in new version) to cut holes in editor, not in runtime?
I’d prefer to scan all graphs in editor and don’t touch them in playmode.

Hi

I don’t think so at the moment.
You may get it to work if you call:

AstarPath.FindAstarPath();
AstarPath.active.navmeshUpdates.OnEnable();
AstarPath.active.navmeshUpdates.Update();

@aron_granberg
Unfortunately there is no such thing as navmeshUpdates in AstarPath class.

It only exists in the beta.

@aron_granberg
When I downloaded package PathfindingProject_Pro_WebsiteDownload_dev_4_1_19_3b555458, it shows 4.1.18, instead of 19. There’s also no chages in the class you mentioned.

Tried twice, file still shows one version less than the last beta.
PathfindingProject_Pro_WebsiteDownload_dev_4_1_19_3b555458.zip

@aron_granberg
Thanks, now the beta version works fine. Unfortunately, the fix you mentioned doesn’t work - the graph still cannot receive cuts in scene mode (outside play mode).