---
title: CreateReadOnly
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/animations/animationstreammask/createreadonly
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/animationstreammask/createreadonly.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:19:37.826Z
locale: en-us
---

# CreateReadOnly

> Creates a read-only AnimationStreamMask from a RigDefinition and a NativeArray of WeightData.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Animations](/engine/7000.0/script-reference/unity/animations.md)
* **Assembly:** [UnityEngine.AnimationCoreModule](/engine/7000.0/script-reference/modules/unityengine-animationcoremodule.md)

## CreateReadOnly(RigDefinition, NativeArray\<WeightData>)

Creates a read-only AnimationStreamMask from a RigDefinition and a NativeArray of WeightData.

```csharp
public static AnimationStreamMask CreateReadOnly(ref RigDefinition rig, NativeArray<WeightData> buffer)
```

### Parameters

**** (\[RigDefinition]\(/engine/7000.0/script-reference/unity/animations/rigdefinition)): The rig definition that describes the layout of the weight data.**** (\[NativeArray\<WeightData>]\(/engine/7000.0/script-reference/unity/collections/nativearray1)): The [NativeArray\<T>](/engine/7000.0/script-reference/unity/collections/nativearray1.md) of [WeightData](/engine/7000.0/script-reference/unity/animations/weightdata.md) that the mask views. Its length must be [BindingSet.StreamMaskSize](/engine/7000.0/script-reference/unity/animations/bindingset/streammasksize.md).

### Returns

| Type                                                                                           | Description                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [AnimationStreamMask](/engine/7000.0/script-reference/unity/animations/animationstreammask.md) | A read-only [AnimationStreamMask](/engine/7000.0/script-reference/unity/animations/animationstreammask.md) that views `buffer`. Returns a default mask if `rig` is a null reference or `buffer` is empty. If safety checks are disabled, also returns a default mask if `buffer` is shorter than [BindingSet.StreamMaskSize](/engine/7000.0/script-reference/unity/animations/bindingset/streammasksize.md). |

## CreateReadOnly(RigDefinition, WeightMaskSampler)

Creates a read-only AnimationStreamMask that reads the weights of a [WeightMaskSampler](/engine/7000.0/script-reference/unity/animations/weightmasksampler.md).

```csharp
public static AnimationStreamMask CreateReadOnly(ref RigDefinition rig, WeightMaskSampler weightMask)
```

### Parameters

**** (\[RigDefinition]\(/engine/7000.0/script-reference/unity/animations/rigdefinition)): The rig definition that describes the layout of the weight data. It must be the rig that the sampler was created for.**** (\[WeightMaskSampler]\(/engine/7000.0/script-reference/unity/animations/weightmasksampler)): The sampler that holds the weights.

### Returns

| Type                                                                                           | Description                                                                |
| ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| [AnimationStreamMask](/engine/7000.0/script-reference/unity/animations/animationstreammask.md) | The read-only mask. A default mask if `rig` or `weightMask` isn't created. |

### Remarks

The mask is a view of the memory of the sampler and uses the safety handle of the sampler. Disposing the mask doesn't release the memory of the sampler. If safety checks are enabled, using the mask after you dispose the sampler throws an `ObjectDisposedException`.
