# GetDefaultWorld()

> Obtains a reference to the navigation mesh world where all navigation operations occur.

## Definition

* **Type:** Method
* **Namespace:** [Unity.AI.Navigation.LowLevel](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel.md)
* **Assembly:** UnityEngine.AIModule

```csharp
public static NavWorld GetDefaultWorld()
```

### Returns

| Type                                                                                 | Description                                                                                                                                                   |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [NavWorld](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld.md) | A reference to the single [NavWorld](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld.md) that can currently exist and be used in Unity. |

### Remarks

The returned world comprises all the NavMesh surfaces and connections that are also used through the [NavMesh](/engine/6000.5/script-reference/unityengine/ai/navmesh.md)-related structures.

The world becomes invalid after a call to [NavMesh.RemoveAllNavMeshData](/engine/6000.5/script-reference/unityengine/ai/navmesh/removeallnavmeshdata.md). A new call to `GetDefaultWorld` returns a world that is different than the one that has been destroyed.

Each call returns a separate handle that holds resources of its own. Pair every call with a [NavWorld.Dispose](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/dispose.md) call, for example through a `using` declaration, otherwise the handles accumulate for as long as the navigation data exists.

Additional Resources: [NavWorld.IsValid](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/isvalid.md), [NavWorld.Dispose](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/dispose.md), [NavMesh.AddNavMeshData](/engine/6000.5/script-reference/unityengine/ai/navmesh/addnavmeshdata.md), [NavMesh.AddLink](/engine/6000.5/script-reference/unityengine/ai/navmesh/addlink.md)

### Examples

```csharp
using UnityEngine;
using Unity.AI.Navigation.LowLevel;

public class GetDefaultWorldExample : MonoBehaviour
{
    NavWorld m_World;

    void OnEnable()
    {
        // Each handle owns a safety handle, so obtain one here and keep
        // it for as long as you run queries, instead of asking for a new
        // handle on every frame.
        m_World = NavWorld.GetDefaultWorld();
    }

    void OnDisable()
    {
        m_World.Dispose();
    }

    void Update()
    {
        if (!m_World.IsValid())
            return;

        NavLocation location =
            m_World.MapLocation(transform.position, 100f * Vector3.one, 0);
        if (m_World.IsValid(location))
            Debug.DrawLine(transform.position, location.position, Color.green);
    }
}
```
