# operator ==(NavWorld, NavWorld)

> Checks whether two NavWorld values refer to the same underlying NavMesh world.

## Definition

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

```csharp
public static bool operator ==(NavWorld left, NavWorld right)
```

### Parameters

**** (\[NavWorld]\(/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld)): The [NavWorld](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld.md) on the left side of the operator.**** (\[NavWorld]\(/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld)): The [NavWorld](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld.md) on the right side of the operator.

### Returns

| Type                                                          | Description                                                                                                                                                            |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the two [NavWorld](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld.md) values reference the same navigation system, `false` otherwise. |

### Remarks

This operator is a syntactic shortcut equivalent to calling [NavWorld.Equals](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld/equals.md). Use it inside expressions where the `==` syntax is more concise than an explicit method call. Two [NavWorld](/engine/6000.5/script-reference/unity/ai/navigation/lowlevel/navworld.md) values are equal only when they point to the same internal navigation system.

### Examples

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

public class NavWorldEqualityExample : MonoBehaviour
{
    NavWorld m_World;
    int m_CachedWorldHash;

    void OnEnable()
    {
        m_World = NavWorld.GetDefaultWorld();
        m_CachedWorldHash = m_World.GetHashCode();
        Debug.Log($"Cached the NavMesh world hash {m_CachedWorldHash}");
        CompareNavigationWorldToPrevious();

        // Destroying all the data makes every existing handle to the old world invalid.
        NavMesh.RemoveAllNavMeshData();
        Debug.Log($"Removed all NavMesh data.");

        //m_CachedWorldHash = m_World.GetHashCode();
        //Debug.Log($"Cached the NavMesh world, hash {m_CachedWorldHash}");
        CompareNavigationWorldToPrevious();
    }

    public void CompareNavigationWorldToPrevious()
    {
        NavWorld currentWorld = NavWorld.GetDefaultWorld();

        // Equals, == and != compare the underlying navigation system rather than the struct
        // copy, so two handles obtained from the same world always compare equal.
        if (currentWorld == m_World)
        {
            Debug.Log($"The navigation world is the same as before.");

            // The handles are interchangeable, so keep one and release the duplicate.
            currentWorld.Dispose();
            return;
        }

        Debug.Log($"The world was re-created: hash {m_CachedWorldHash} became {currentWorld.GetHashCode()}");

        // Release the stale handle before replacing it, otherwise its safety handle leaks.
        m_World.Dispose();
        m_World = currentWorld;
        m_CachedWorldHash = m_World.GetHashCode();
    }

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