Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


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

bytesThe raw bytes of the text asset. (Read Only)
dataSizeThe size of the text asset data in bytes. (Read Only)
textThe text contents of the file as a string. (Read Only)

Methods

Method

Description

GetDataGets raw text asset data.
ToStringReturns the contents of the TextAsset as a read-only string.

Inheritance

Inherited Members

Operators

Operator

Description

operator ==Compares two object references to see if they refer to the same object.
boolDetermines whether the object exists.
operator !=Compares if two objects refer to a different object.