Hi
in my game login , i need manualy add NavmeshCut to gameobject to cut special layer
navCut = gameObject.AddComponent<NavmeshCut>();
navCut.rectangleSize = new Vector2(3, 3);
navCut.graphMask = GraphMask.FromGraphName("CustomName");
//This three line must add together to make it work
navCut.ForceUpdate();
navCut.enabled = false;
navCut.enabled = true;
first try only call navCut.ForceUpdate()
but can’t get the right result.
so i check the code in NavmeshCutEditor
if (EditorGUI.EndChangeCheck()) {
foreach (NavmeshCut tg in targets) {
tg.ForceUpdate();
// If the mask is changed we disable and then enable the component
// to make sure it is removed from the right graphs and then added back
if (changedMask && tg.enabled) {
tg.enabled = false;
tg.enabled = true;
}
}
}
it look like need call
navCut.ForceUpdate();
navCut.enabled = false;
navCut.enabled = true;
three line together to get it work.
so . maybe it’s good to add a fcuntion or hook the graphMask set function to get a better experience?
thanks.