Txt文件读取《一》

使用 TextAsset读取txt文件

    //存放Txt中所有文字的数组
    public string[] strs;
    void Start()
    {
        //从Resources目录读取文件
        TextAsset txt = Resources.Load("teachtxt") as TextAsset;
        strs = txt.text.Split('\n');
        
        Debug.Log(strs[0]);
    }
Txt文件读取《一》_第1张图片
注意格式.png

你可能感兴趣的:(Txt文件读取《一》)