Search Unity

  1. We want you to join us at GDC this year! Take a peek at all of the events we will be hosting during the week of GDC.
    Dismiss Notice
  2. Tell us about your experience here and you’ll get early access to the 2018 Game Studios report + more goodies.
    Dismiss Notice
  3. Unity 2017.3 has arrived! Read about it here.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  5. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice

Clear NavMeshSurface

Discussion in 'Navigation' started by lofwyre, Feb 13, 2018 at 10:26 AM.

  1. lofwyre

    lofwyre

    Joined:
    Apr 19, 2007
    Posts:
    125
    How do you clear a NavMeshSurface?

    I have tried

    Code (CSharp):
    1. NavMeshData.Destroy(CurrentFloorInstance.GetComponent<NavMeshSurface>().navMeshData);
    and

    Code (CSharp):
    1. CurrentFloorInstance.GetComponent<NavMeshSurface>().navMeshData = new NavMeshData();
    and

    Code (CSharp):
    1. CurrentFloorInstance.GetComponent<NavMeshSurface>().RemoveData();
    I'm using GetComponent<NavMeshSurface>().BuildNavMesh() on load of a level to build it. But on each level load the nav mesh data from the previous level still seems to be there as well.

    Additionaly I'm destroying the gameObject the navmesh component is on at the start of the level. But it seems when I instantiate it again, the old navmesh data is still hanging around.

    Cheers
    Matt