Equals
Checks whether two NavQueryBuffer values refer to the same underlying pathfinding buffer.
Read time 2 minutesLast updated 8 hours ago
Definition
- Type: Method
- Namespace: Unity.AI.Navigation.LowLevel
- Assembly: UnityEngine.AIModule
Equals(NavQueryBuffer)
Checks whether two NavQueryBuffer values refer to the same underlying pathfinding buffer.
public readonly bool Equals(NavQueryBuffer other)
Parameters
A to compare this one with.
NavQueryBufferReturns
Type | Description |
|---|---|
| bool | |
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 values are identical.
maxNodesToVisitExamples
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 and compare this one with.
NavQueryBufferReturns
Type | Description |
|---|---|
| bool | |
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 values are identical. If isn't a , the method returns .
maxNodesToVisitobjNavQueryBufferfalseExamples
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(); }}