リテラシーユニティTXTドキュメント

void CreateOrOPenFile(List<string> baocun)
    {
        if (fi.Exists)
        {
            fi.Delete();
        }
        //路径、文件名、写入内容
        StreamWriter sw;
        fi = new FileInfo(Application.streamingAssetsPath + "/coordinates.txt");
        sw = fi.CreateText();        //直接重新写入,如果要在原文件后面追加内容,应用fi.AppendText()
        for (int i = 0; i < baocun.Count; i++)
        {
            sw.WriteLine(baocun[i]);
        }
        sw.Close();
        sw.Dispose();
    }

    IEnumerator LoadFileAndIntialSpeed()
    {
        StreamReader sr = null;
        sr = File.OpenText(Application.dataPath + "/StreamingAssets/coordinates.txt");
        string dirs = sr.ReadToEnd();
        string[] infoArray = dirs.Split('\n');
        foreach (string str in infoArray)
        {
            if (str.Contains("@"))
            {
                string[] allArray = str.Split('@');
                string id = allArray[0];
                string currentInfo = allArray[1].Replace("\r", "");
                mInfo.Add(id, currentInfo);
            }
        }
        foreach (var item in mInfo)
        {
            bianli++;
            string a = item.Key;
            string b = item.Value;
            triggerPos[bianli].anchoredPosition = new Vector2(float.Parse(a),float.Parse(b));
            Debug.Log(a + "@" + b);
        }
        yield return sr;
        sr.Close();
        sr.Dispose();
    }

https://blog.csdn.net/hehe_CSDNALS/article/details/89950201より転載

リリース元の4件の記事 ウォンの賞賛1 ビュー1332

おすすめ

転載: blog.csdn.net/obf2018/article/details/89950238