Skip to main content

There's a class named TextAssets which is used for text file readreading. http://docs.unity3d.com/Manual/class-TextAsset.html hereHere you can find the supported file format.

soSo if uyou want to read read the text file, the script would be like this:

class YourClassName : MonoBehaviour{
    public TextAsset textFile;     // drop your file here in inspector

    void Start(){
        string text = textFile.text;  //this is the content as string
        byte[] byteText = textFile.bytes;  //this is the content as byte array
    }
}

or you can read the text as resource like this:

TextAsset text = Resources.Load("YourFilePath") as TextAsset;

There's class named TextAssets which is used for text file read. http://docs.unity3d.com/Manual/class-TextAsset.html here you can find the supported file format.

so if u want to read read the text file, script would be like this:

class YourClassName : MonoBehaviour{
    public TextAsset textFile;     // drop your file here in inspector

    void Start(){
        string text = textFile.text;  //this is the content as string
        byte[] byteText = textFile.bytes;  //this is the content as byte array
    }
}

or you can read the text as resource like this:

TextAsset text = Resources.Load("YourFilePath") as TextAsset;

There's a class named TextAssets which is used for text file reading. http://docs.unity3d.com/Manual/class-TextAsset.html Here you can find the supported file format.

So if you want to read the text file, the script would be like this:

class YourClassName : MonoBehaviour{
    public TextAsset textFile;     // drop your file here in inspector

    void Start(){
        string text = textFile.text;  //this is the content as string
        byte[] byteText = textFile.bytes;  //this is the content as byte array
    }
}

or you can read the text as resource like this:

TextAsset text = Resources.Load("YourFilePath") as TextAsset;
Source Link
Listen
  • 431
  • 1
  • 3
  • 5

There's class named TextAssets which is used for text file read. http://docs.unity3d.com/Manual/class-TextAsset.html here you can find the supported file format.

so if u want to read read the text file, script would be like this:

class YourClassName : MonoBehaviour{
    public TextAsset textFile;     // drop your file here in inspector

    void Start(){
        string text = textFile.text;  //this is the content as string
        byte[] byteText = textFile.bytes;  //this is the content as byte array
    }
}

or you can read the text as resource like this:

TextAsset text = Resources.Load("YourFilePath") as TextAsset;