Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Clear NavMeshSurface

Discussion in 'Navigation' started by lofwyre, Feb 13, 2018.

  1. lofwyre

    lofwyre

    Joined:
    Apr 19, 2007
    Posts:
    131
    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