码迷,mamicode.com
首页 > 编程语言 > 详细

unity中CSV的读取

时间:2017-03-15 00:15:48      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:介绍   unity   file   catch   void   load   amr   parse   return   

unity中读取数据的格式有很多种,现在为大家介绍的是读取CSV,

static CSV csv;
public List<string[]> m_ArratData;


public static CSV Getinstance()
{
if (csv == null)
{
csv = new CSV();
}
return csv;
}
public string getstring(int row, int col)
{
return m_ArratData[row][col];
}
public int getInt(int row, int col)
{
return int.Parse(m_ArratData[row][col]);
}

private CSV() {
m_ArratData = new List<string[]>();
}

public void loadFile(string path,string fileName)
{
m_ArratData.Clear();
StreamReader sr = null;
try
{
sr = File.OpenText(path + "//" + fileName);
Debug.Log("file is finded!");
}
catch
{
Debug.Log("file dont not exist");
}
string line;
while ((line = sr.ReadLine()) != null)
{
m_ArratData.Add(line.Split(‘,‘));
}
sr.Close();
sr.Dispose();

}

}

unity中CSV的读取

标签:介绍   unity   file   catch   void   load   amr   parse   return   

原文地址:http://www.cnblogs.com/carsonche/p/6551424.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!