# TextAsset

> Creates a new TextAsset with specified text contents.

## Definition

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

## TextAsset()

Creates a new [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) with specified text contents.

```csharp
public TextAsset()
```

### Remarks

This constructor creates a [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md), not a plain text file. To save a [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) to disk using the [AssetDatabase](/engine/6000.6/script-reference/unityeditor/assetdatabase.md) class, save the [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) with the .asset extension.

## TextAsset(string)

Creates a new [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) with specified text contents.

```csharp
public TextAsset(string text)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The text contents for the [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md).

### Remarks

This constructor creates a [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md), not a plain text file. To save a [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) to disk using the [AssetDatabase](/engine/6000.6/script-reference/unityeditor/assetdatabase.md) class, save the [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) with the .asset extension.

## TextAsset(ReadOnlySpan\<byte>)

Creates a new [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) with specified byte contents.

```csharp
public TextAsset(ReadOnlySpan<byte> bytes)
```

### Parameters

**** (\[ReadOnlySpan\<byte>]\(https\://learn.microsoft.com/dotnet/api/system.readonlyspan-1)): The byte contents for the [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md).

### Remarks

This constructor creates a [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md), not a plain text file. To save a [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) to disk using the [AssetDatabase](/engine/6000.6/script-reference/unityeditor/assetdatabase.md) class, save the [TextAsset](/engine/6000.6/script-reference/unityengine/textasset.md) with the .asset extension.

Use this form of the constructor to specify an arbitrary byte buffer to store in the TextAsset. Use the [TextAsset.bytes](/engine/6000.6/script-reference/unityengine/textasset/bytes.md) property to access this data or use the [TextAsset.text](/engine/6000.6/script-reference/unityengine/textasset/text.md) property to interpret the byte data as text.
