# GetData<T>()

> Gets raw text asset data.

## Definition

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

```csharp
public NativeArray<T> GetData<T>() where T : struct
```

### Returns

| Type                                                                                 | Description                                                                        |
| ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- |
| [NativeArray\<T>](/engine/6000.5/script-reference/unity/collections/nativearray1.md) | A reference to an array in native code that provides access to the raw asset data. |

### Remarks

It works similarly to the [TextAsset.bytes](/engine/6000.5/script-reference/unityengine/textasset/bytes.md) property, but TextAsset.GetData doesn't allocate any memory; the `NativeArray` the function returns points directly to the asset data buffer.

Because this array doesn't represent a new allocation, you don't need to call `Dispose` on it and the TextAsset.GetData function is the fastest way to access raw asset bytes as a result.

If the text asset is modified or destroyed, the array becomes invalid since it now points to invalid memory.

If the asset data size (see [TextAsset.dataSize](/engine/6000.5/script-reference/unityengine/textasset/datasize.md)) isn't a multiple of the size of the `T` struct, Unity throws an exception.

Additional Resources: [TextAsset.bytes](/engine/6000.5/script-reference/unityengine/textasset/bytes.md), [TextAsset.text](/engine/6000.5/script-reference/unityengine/textasset/text.md), [TextAsset.dataSize](/engine/6000.5/script-reference/unityengine/textasset/datasize.md), [Text Assets](/engine/6000.5/manual/assets-and-media/asset-types/class-text-asset.md).
