public class Student
{
public string id;
public string name;
public string sex;
public string score;
}
public class GetTXTData
{
public Dictionary<string, Student> dic = new Dictionary<string, Student>();
public void GetData()
{
//在Unity工程中的Asset中新建Resources文件夹,把TXT文件放在此文件夹中
TextAsset allData = Resources.Load<TextAsset>("Students");
//获取每一行的数据
string[] lineData = allData.text.Split('\n');
for (int i = 1; i < lineData.Length; i++)
{
string item = lineData[i];
//获取每一项的数据
string[] data = item.Split('|');
Student stu = new Student();
int index = 0;
stu.id = data[index++
{
public string id;
public string name;
public string sex;
public string score;
}
public class GetTXTData
{
public Dictionary<string, Student> dic = new Dictionary<string, Student>();
public void GetData()
{
//在Unity工程中的Asset中新建Resources文件夹,把TXT文件放在此文件夹中
TextAsset allData = Resources.Load<TextAsset>("Students");
//获取每一行的数据
string[] lineData = allData.text.Split('\n');
for (int i = 1; i < lineData.Length; i++)
{
string item = lineData[i];
//获取每一项的数据
string[] data = item.Split('|');
Student stu = new Student();
int index = 0;
stu.id = data[index++