persistentDataPath

作者:追风剑情 发布于:2014-9-12 23:13 分类:Unity3d

using UnityEngine;
using System.Collections;
using System.IO;
using System.Text;

public class PersistentDataPathTest : MonoBehaviour {

    string path;

	void Start () {
        //可以把游戏数据持久化到此目录下
        //当软件被卸载后,此目录下的数据也会同时被清除掉。
        path = Application.persistentDataPath + "/test.txt";
        WriteText("test data");
	}

    void WriteText(string content)
    {
        StreamWriter sw = new StreamWriter(path, false, Encoding.UTF8);
        sw.WriteLine(content);
        sw.Flush();
        sw.Close();
    }

    string ReadText()
    {
        StreamReader sr = new StreamReader(path);
        string content = sr.ReadToEnd();
        sr.Close();
        return content;
    }
}

内置SD卡->Android->data

path.png

IOS只能把资源下载到temporaryCachePath才能通过审核。

标签: Unity3d

Powered by emlog  蜀ICP备18021003号-1   sitemap

川公网安备 51019002001593号