# 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>.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.7/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

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

Checks whether each `EntityID` in a [NativeArray\<T>](/engine/6000.7/script-reference/unity/collections/nativearray1.md) corresponds to a valid [Object](/engine/6000.7/script-reference/unityengine/object.md) in memory, and writes the result for each to a given [NativeArray\<T>](/engine/6000.7/script-reference/unity/collections/nativearray1.md).

```csharp
public static void EntityIdsToValidArray(NativeArray<EntityId> entityIDs, NativeArray<bool> validArray)
```

### Parameters

**** (\[NativeArray\<EntityId>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): The `EntityID`s of the [Object](/engine/6000.7/script-reference/unityengine/object.md) instances to check.**** (\[NativeArray\<bool>]\(/engine/6000.7/script-reference/unity/collections/nativearray1)): 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](/engine/6000.7/script-reference/unityengine/object.md), otherwise `false`. Must be the same length as `entityIDs`.

### Remarks

It can be useful to call this method to determine if an [Object](/engine/6000.7/script-reference/unityengine/object.md) might have been deleted or isn't loaded into memory yet. This is similar to [Resources.EntityIdIsValid](/engine/6000.7/script-reference/unityengine/resources/entityidisvalid.md) 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](/engine/6000.7/script-reference/unityengine/object.md) in memory, and writes the result for each to a given array.

```csharp
public static void EntityIdsToValidArray(ReadOnlySpan<EntityId> entityIds, Span<bool> validArray)
```

### Parameters

**** (\[ReadOnlySpan\<EntityId>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The `EntityID`s of the [Object](/engine/6000.7/script-reference/unityengine/object.md) instances to check.**** (\[Span\<bool>]\(https\://learn.microsoft.com/dotnet/api/system.span-1)): 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](/engine/6000.7/script-reference/unityengine/object.md), otherwise `false`. Must be the same length as `entityIds`.

### Remarks

This is similar to [Resources.EntityIdIsValid](/engine/6000.7/script-reference/unityengine/resources/entityidisvalid.md) but checks several `EntityID`s at once. `entityIds` and `validArray` must be the same length, otherwise the method throws an `ArgumentException`.
