Old Navmesh Data stay with rebuild

Hello everyone,
I have problems with buildnig navmesh surface on procedural maze.
For the first build, all its ok, the navmesh surface is correctly builded :


But with a second generation of maze, the ancient navmesh surface data seems to be here again

I tried to use Navmesh.RemoveData(), but the problem still persist when i reuse Navmesh.BuildNavMesh().
I saw some people with the same problem, but no solutions were posted.

Anyone with a solution ?

Did you find any solution to this problem? I have the same issue as you where i initiate levels as prefabs on one scene. NavmeshSurface keep its old data even if i use RemoveData() function. It also visualize like its clearing the data when i observe it from the scene but ols data keeps coming back even if new level is initiated.

  1. Do a Navmesh.RemoveData
  2. Skip a Frame
  3. Then NavMesh.BuildNavMesh

NavMesh.RemoveAllNavMeshData(); // work for me

I think this is due to the old objects being queued for Destroy() behind the scenes. So think like skipping frames before the BuildNavMesh may work but are likely to be indeterministic. A more reliable solution is to deactivate the game object before calling Destroy:-

        oldGameObject.SetActive(false);
        Destroy(oldGameObject);

The BuildNavMesh should now ignore the old object even if the Destroy is queued.,I think this is due to the old objects being queued for Destroy() behind the scenes. So think like skipping frames before the BuildNavMesh may work but are likely to be indeterministic. A more reliable solution is to deactivate the game object before calling Destroy:-

        oldGameObject.SetActive(false);
        Destroy(oldGameObject);

The BuildNavMesh should now ignore the old object even if the Destroy is queued.