Esempio n. 1
0
    //[MenuItem("Tools/Write file")]
    void WriteString()
    {
        string path = "";

        string[] resultLog = new string[1];
        if (platform == RuntimePlatform.OSXEditor || platform == RuntimePlatform.OSXPlayer || platform == RuntimePlatform.WindowsEditor || platform == RuntimePlatform.WindowsPlayer)
        {
            //path = Application.persistentDataPath + "/testLog.txt";
            path = Application.persistentDataPath + "testLog.txt";
            Debug.Log(path);
            resultLog[0] = infoBrg.getAccessLog();
            //Write some text to the test.txt file
            StreamWriter writer = new StreamWriter(path, true);
            writer.WriteLine(resultLog[0]);
            writer.Close();

            string path2 = Application.persistentDataPath + infoBrg.getTitleInfor() + infoBrg.getTitleNum() + ".txt";
            Debug.Log(path2);
            StreamWriter writePos = new StreamWriter(path2, true);
            writePos.WriteLine(trackPosition[0] + "\r\n");
            writePos.Close();
        }
        else if (platform == RuntimePlatform.Android || platform == RuntimePlatform.IPhonePlayer)
        {
            //path = "/root/storage/sdcard1/test.txt";
            path = Application.persistentDataPath + "/test.txt";
            //EasyTTSUtil.SpeechAdd("android");
            Debug.Log(path);
            resultLog[0] = infoBrg.getAccessLog();
            //Write some text to the test.txt file
            File.WriteAllLines(path, resultLog);
            string path2 = Application.persistentDataPath + infoBrg.getTitleInfor()
                           + infoBrg.getTitleNum() + ".txt";
            File.WriteAllLines(path2, trackPosition);
        }


        //Re-import the file to update the reference in the editor
        //AssetDatabase.ImportAsset(path);
        //TextAsset asset = Resources.Load("test");

        //Print the text from the file
        //Debug.Log(asset.text);
    }