定义CSV配置表如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
/// <summary>
/// CSV解析
/// </summary>
public class Analysis_CSV : MonoBehaviour
{
void Start()
{
string str = File.ReadAllText(Application.dataPath + "/Resources/Test_CSV.csv");//根目录加载
//string str = File.ReadAllText("Assets/Resources/Test_CSV.csv");//Resources文件夹加载
Debug.Log(str);
string[] strArr = str.Split("\r\n");// "\r"回车 "\n"换行
for (int i = 1; i < strArr.Length - 1; i++)
{
Debug.Log("ID:::::"+strArr[i].Split(',')[0]);
Debug.Log("Name:::::" + strArr[i].Split(',')[1]);
Debug.Log("Type:::::" + strArr[i].Split(',')[2]);
}
}
}