Unity TextAsset

xiaoxiao2021-02-28  128

TextAsset支持的文件类型有:

.txt .html .htm .xml .bytes .json .csv .yaml .fnt

一.读取txt文档

1.在Resources下创建文件夹Data,在Data文件夹下创建Hello.txt文件,在里面输入一些内容

2.绑定一个C#脚本在Main Camera上

3.编辑脚本,代码如下

public class MainCamera : MonoBehaviour { // Use this for initialization void Start () {         TextAsset text = Resources.Load("Data\\Hello") as TextAsset;         Debug.Log(text.text);     } }

转载请注明原文地址: https://www.6miu.com/read-50517.html

最新回复(0)