/// <summary>
/// <para>Builds the combined navmesh for the contents of multiple scenes.</para>
/// </summary>
/// <param name="paths">Array of paths to scenes that are used for building the navmesh.</param>
public static void BuildNavMeshForMultipleScenes(string[] paths)
{
if (paths.Length == 0)
{
return;
}
for (int index1 = 0; index1 < paths.Length; ++index1)
{
for (int index2 = index1 + 1; index2 < paths.Length; ++index2)
{
if (paths[index1] == paths[index2])
{
throw new Exception("No duplicate scene names are allowed");
}
}
}
if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
{
return;
}
if (!EditorSceneManager.OpenScene(paths[0]).IsValid())
{
throw new Exception("Could not open scene: " + paths[0]);
}
for (int index = 1; index < paths.Length; ++index)
{
EditorSceneManager.OpenScene(paths[index], OpenSceneMode.Additive);
}
NavMeshBuilder.BuildNavMesh();
UnityEngine.Object sceneNavMeshData = NavMeshBuilder.sceneNavMeshData;
for (int index = 0; index < paths.Length; ++index)
{
if (EditorSceneManager.OpenScene(paths[index]).IsValid())
{
NavMeshBuilder.sceneNavMeshData = sceneNavMeshData;
EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
}
}
}