---
title: Equals
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navquerybuffer/equals
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navquerybuffer/equals.md
last_updated: 2026-11-30
generated_at: 2026-12-01T01:18:23.439Z
locale: en-us
---

# Equals

> Checks whether two NavQueryBuffer values refer to the same underlying pathfinding buffer.

## Definition

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

## Equals(NavQueryBuffer)

Checks whether two NavQueryBuffer values refer to the same underlying pathfinding buffer.

```csharp
public readonly bool Equals(NavQueryBuffer other)
```

### Parameters

**** (\[NavQueryBuffer]\(/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navquerybuffer)): A `NavQueryBuffer` to compare this one with.

### Returns

| Type                                                          | Description                                                                                                    |
| ------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if the two `NavQueryBuffer` values refer to the same underlying pathfinding buffer. Otherwise, `false`. |

### Remarks

The comparison checks whether both values point to the same allocation in memory. Two [NavQueryBuffer](/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navquerybuffer.md) instances that were created by separate calls to the [NavQueryBuffer](/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navquerybuffer/ctor.md) constructor are never equal, even if their `maxNodesToVisit` values are identical.

### Examples

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

// Attach this script to a GameObject and enter Play mode. The Console shows two messages:
// a and b share an allocation, and a and c don't.
public class NavQueryBufferEqualsExample : MonoBehaviour
{
    void OnEnable()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavQueryBuffer a = new NavQueryBuffer(world, Allocator.Persistent, 1024);
        NavQueryBuffer b = a;
        NavQueryBuffer c = new NavQueryBuffer(world, Allocator.Persistent, 1024);

        if (a.Equals(b))
            Debug.Log("Both a and b handles share the same allocation.");

        if (!a.Equals(c))
            Debug.Log("The a and c handles have been allocated separately.");

        a.Dispose();
        c.Dispose();
    }
}
```

## Equals(Object)

Checks whether an object is a NavQueryBuffer that refers to the same underlying pathfinding buffer.

```csharp
public override readonly bool Equals(object obj)
```

### Parameters

**** (\[Object]\(https\://learn.microsoft.com/dotnet/api/system.object)): An object to interpret as a `NavQueryBuffer` and compare this one with.

### Returns

| Type                                                          | Description                                                                                                      |
| ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [bool](https://learn.microsoft.com/dotnet/api/system.boolean) | `true` if `obj` is a `NavQueryBuffer` that refers to the same underlying pathfinding buffer. Otherwise, `false`. |

### Remarks

The comparison checks whether both values point to the same allocation in memory. Two [NavQueryBuffer](/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navquerybuffer.md) instances that were created by separate calls to the [NavQueryBuffer](/engine/7000.0/script-reference/unity/ai/navigation/lowlevel/navquerybuffer/ctor.md) constructor are never equal, even if their `maxNodesToVisit` values are identical. If `obj` isn't a `NavQueryBuffer`, the method returns `false`.

### Examples

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

// Attach this script to a GameObject and enter Play mode. The Console shows two messages:
// a and b share an allocation, and a and c don't.
public class NavQueryBufferEqualsExample : MonoBehaviour
{
    void OnEnable()
    {
        using NavWorld world = NavWorld.GetDefaultWorld();
        NavQueryBuffer a = new NavQueryBuffer(world, Allocator.Persistent, 1024);
        NavQueryBuffer b = a;
        NavQueryBuffer c = new NavQueryBuffer(world, Allocator.Persistent, 1024);

        if (a.Equals(b))
            Debug.Log("Both a and b handles share the same allocation.");

        if (!a.Equals(c))
            Debug.Log("The a and c handles have been allocated separately.");

        a.Dispose();
        c.Dispose();
    }
}
```
