在Assets下创建一个文件夹,命名:Resources
将需要读取的txt文件放入该文件夹,
代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
TextAsset t;
void Start()
{
//从Resources文件夹下,以TextAsset类型,读取命名MyText的文件,并赋值给t
t = Resources.Load<TextAsset>("MyText")