Documentation

Unity Engine

Download Unity

Unity Engine

Equals

Checks whether two NavQueryBuffer values refer to the same underlying pathfinding buffer.
Read time 2 minutesLast updated 8 hours ago

Definition

Equals(NavQueryBuffer)

Checks whether two NavQueryBuffer values refer to the same underlying pathfinding buffer.
public readonly bool Equals(NavQueryBuffer other)

Parameters

A
NavQueryBuffer
to compare this one with.

Returns

Type

Description

bool
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 instances that were created by separate calls to the NavQueryBuffer constructor are never equal, even if their
maxNodesToVisit
values are identical.

Examples

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.
public override readonly bool Equals(object obj)

Parameters

An object to interpret as a
NavQueryBuffer
and compare this one with.

Returns

Type

Description

bool
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 instances that were created by separate calls to the NavQueryBuffer constructor are never equal, even if their
maxNodesToVisit
values are identical. If
obj
isn't a
NavQueryBuffer
, the method returns
false
.

Examples

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(); }}