TextAsset
Represents a raw text or binary file asset.
Read time 4 minutesLast updated 2 days ago
Definition
- Type: Class
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
- Inherits from: Object
public class TextAsset : Object
Remarks
You can use raw text files in your project as assets and get their contents through this class. For more information, see TextAsset.text.
You can access the file as a raw byte array to access data from binary files. For more information on how to access data from binary files, see TextAsset.bytes and TextAsset.GetData.
For more information about importing text or binary files into your project as Text Assets, see Text Asset.
Constructors
Constructor | Description |
|---|---|
| TextAsset() | Creates a new TextAsset with specified text contents. |
| TextAsset(System.ReadOnlySpan{System.Byte}) | Creates a new TextAsset with specified byte contents. |
| TextAsset(System.String) | Creates a new TextAsset with specified text contents. |
Properties
Property | Description |
|---|---|
| bytes | The raw bytes of the text asset. (Read Only) |
| dataSize | The size of the text asset data in bytes. (Read Only) |
| text | The text contents of the file as a string. (Read Only) |
Methods
Method | Description |
|---|---|
| GetData | Gets raw text asset data. |
| ToString | Returns the contents of the TextAsset as a read-only string. |
Inheritance
Operators
Operator | Description |
|---|---|
| operator == | Compares two object references to see if they refer to the same object. |
| bool | Determines whether the object exists. |
| operator != | Compares if two objects refer to a different object. |