Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


EntityIdsToValidArray

Checks whether each EntityID in a NativeArray<T> corresponds to a valid Object in memory, and writes the result for each to a given NativeArray<T>.
Read time 2 minutesLast updated 14 days ago

Definition

  • Type: Method
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule

EntityIdsToValidArray(NativeArray<EntityId>, NativeArray<bool>)

Checks whether each
EntityID
in a NativeArray<T> corresponds to a valid Object in memory, and writes the result for each to a given NativeArray<T>.
public static void EntityIdsToValidArray(NativeArray<EntityId> entityIDs, NativeArray<bool> validArray)

Parameters

The
EntityID
s of the Object instances to check.

The array that receives the results. The method sets each element to
true
if the
EntityID
at the same index in
entityIDs
corresponds to a valid Object, otherwise
false
. Must be the same length as
entityIDs
.

Remarks

It can be useful to call this method to determine if an Object might have been deleted or isn't loaded into memory yet. This is similar to Resources.EntityIdIsValid but checks several
EntityID
s at once. Both arrays must be initialized and the same length, otherwise the method throws an
ArgumentException
.

EntityIdsToValidArray(ReadOnlySpan<EntityId>, Span<bool>)

Checks whether each
EntityID
in an array corresponds to a valid Object in memory, and writes the result for each to a given array.
public static void EntityIdsToValidArray(ReadOnlySpan<EntityId> entityIds, Span<bool> validArray)

Parameters

The
EntityID
s of the Object instances to check.

validArray

The span that receives the results. The method sets each element to
true
if the
EntityID
at the same index in
entityIds
corresponds to a valid Object, otherwise
false
. Must be the same length as
entityIds
.

Remarks

This is similar to Resources.EntityIdIsValid but checks several
EntityID
s at once.
entityIds
and
validArray
must be the same length, otherwise the method throws an
ArgumentException
.