unity Android csv 数据持久化

unity读写csv参照这里:
http://www.cocoachina.com/game/20151217/14727.html

下列代码解决关于在Android端找不到.csv文件的问题,亲测有效

    public void loadResourcesFile(string fileName) {
        strArrList.Clear();
        StreamReader sr = null;
        try {
            sr = new StreamReader(new MemoryStream((Resources.Load(fileName) as TextAsset).bytes));
            Debug.Log("file finded!");
        }
        catch {
            Debug.Log("file don't finded!");
            return;
        }
        string line;
        while ((line = sr.ReadLine()) != null) {
            strArrList.Add(line.Split(','));
        }
        sr.Close();
        sr.Dispose();
    }
        csv.loadResourcesFile("EnemyLayout2");

你可能感兴趣的:(Android,Unity)