unity 清空控制台temporarycachepath什么时候会清空

16123人阅读
Unity3D(3)
Application.dataPath : & & & & & & & & & &Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data
Application.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw
Application.persistentDataPath : & &Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
Application.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/Caches
Application.dataPath :& /data/app/xxx.xxx.xxx.apk
Application.streamingAssetsPath :& jar:file:///data/app/xxx.xxx.xxx.apk/!/assets
Application.persistentDataPath :& /data/data/xxx.xxx.xxx/files
Application.temporaryCachePath :& /data/data/xxx.xxx.xxx/cache
Windows Web Player:
Application.dataPath :& file:///D:/MyGame/WebPlayer (即导包后保存的文件夹,html文件所在文件夹)
Application.streamingAssetsPath :&
Application.persistentDataPath :&
Application.temporaryCachePath :
---------------------------------------------------------------------------------------------------
各目录权限:
根目录:StreamingAssets文件夹
#if UNITY_EDITOR
string filepath = Application.dataPath +&/StreamingAssets&+&/my.xml&;
#elif UNITY_IPHONE
&string filepath = Application.dataPath +&/Raw&+&/my.xml&;
#elif UNITY_ANDROID
&string filepath = &jar:file://& + Application.dataPath + &!/assets/&+&/my.
根目录:Resources 文件夹
可以使用Resources.Load(&名字&); 把文件夹中的对象加载出来
根目录:StreamingAssets 文件夹
可以使用Application.dataPath进行读操作
Application.dataPath: 只可读不可写,放置一些资源数据
Application.persistentDataPath
IOS与android平台都可以使用这个目录下进行读写操作,可以存放各种配置文件进行修改之类的。
在PC上的地址是:C:\Users\用户名 \AppData\LocalLow\DefaultCompany\test
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:513966次
积分:5901
积分:5901
排名:第3537名
原创:131篇
转载:44篇
评论:56条
(1)(2)(1)(1)(1)(2)(1)(1)(1)(1)(3)(2)(5)(1)(3)(2)(5)(2)(7)(5)(1)(3)(1)(4)(3)(2)(5)(3)(5)(4)(2)(2)(2)(3)(6)(1)(5)(4)(5)(5)(1)(3)(1)(5)(1)(2)(3)(2)(1)(1)(2)(1)(2)(3)(1)(1)(1)(1)(1)(1)(1)(1)(3)(1)(1)(1)(3)(1)(1)(1)(2)(1)(2)(1)(2)(1)(1)(1)(1)(2)(1)Posts - 216,
Articles - 0,
Comments - 17
记录自己学习笔记和讨论技术的小窝。
11:36 by 阿诚de窝, ... 阅读,
文件夹及路径
昨天记了一篇AssetBundle学习笔记,那么游戏中的各种资源应该如何存放呢?
在网上一阵搜罗,把笔记记一下。
非特殊名称文件夹
非Unity3D指定名称的文件夹中的资源,如果游戏场景中有使用到,发布时会被一同打包,没有使用到则不会被打包。
开发时可使用Application.dataPath来对根目录下的文件进行任意操作,但是发布到移动端后App是没有权限操作根目录的。
Resources文件夹
存放到该文件夹下的所有文件,无论场景中是否使用到,都会被打包。
但是资源在打包后只能使用Resource.Load进行读取,不能对资源进行修改和删除等操作。
StreamingAssets文件夹
存放到该文件夹下的所有文件,无论场景中是否使用到,也都会被打包。
使用Application.streamingAssetsPath可以获取到该目录,在PC端可以对该文件夹进行读写操作,在移动端只能对该文件夹进行读操作。
这个文件夹下的资源也会全都打包在.apk或者.ipa 它和Resources的区别是,Resources会压缩文件,但是它不会压缩原封不动的打包进去。并且它是一个只读的文件夹,就是程序运行时只能读 不能写。它在各个平台下的路径是不同的,不过你可以用Application.streamingAssetsPath 它会根据当前的平台选择对应的路径。
有些游戏为了让所有的资源全部使用assetbundle,会把一些初始的assetbundle放在StreamingAssets目录下,运行程序的时候在把这些assetbundle拷贝在Application.persistentDataPath目录下,如果这些assetbundle有更新的话,那么下载到新的assetbundle在把Application.persistentDataPath目录下原有的覆盖掉。(终于知道手游第一次进入时解压资源是在干什么了!)
StreamingAssets目录下的资源都是不压缩的,所以它比较大会占空间,比如你的应用装在手机上会占用100M的容量,那么你又在StreamingAssets放了一个100M的assetbundle,那么此时在装在手机上就会在200M的容量。
Application.persistentDataPath路径
该路径在Unity3D根目录下没有对应的文件夹,该路径指向设备上的公共目录。
因为Application.persistentDataPath目录是应用程序的沙盒目录,所以打包之前是没有这个目录的,直到应用程序在手机上安装完毕才有这个目录。
该文件存在手机沙盒中,因为不能直接存放文件:
通过服务器直接下载保存到该位置,也可以通过Md5码比对下载更新新的资源
没有服务器的,只有间接通过文件流的方式从本地读取并写入Application.persistentDataPath文件下,然后再通过Application.persistentDataPath来读取操作。
注:在Pc/Mac电脑 以及Android跟Ipad、ipone都可对文件进行任意操作,另外在IOS上该目录下的东西可以被iCloud自动备份。
Application.temporaryCachePath路径
操作方式跟上面Application.persistentDataPath类似。除了在IOS上不能被iCloud自动备份。
Application.persistentDataPath没有读取文件的问题
//安卓上跟其他平台不一样,安装后,这些文件实际上是在一个Jar压缩包里,所以不能直接用读取文件的函数去读,而要用WWW方式。具体做法如下: //1.把你要读取的文件放在Unity项目的Assets/StreamingAssets文件夹下面,没有这个文件夹的话自己建一个。 //2.读取的代码(假设名为"文件.txt") byte[] InB
//用来存储读入的数据 if (Application.platform == RuntimePlatform.Android)
//判断当前程序是否运行在安卓下 {
string FileName = "jar:file://" + Application.dataPath + "!/assets/" + "文件.txt";
WWW www = new WWW(FileName);
//WWW会自动开始读取文件
while(!www.isDone){}
//WWW是异步读取,所以要用循环来等待
InBytes = www.
//存到字节数组里
//其他平台的读取代码 }
Unity3D研究院之IOS Android支持中文与本地文件的读取写入
unity 在移动平台中,文件操作路径详解
Unity中的Path对应各平台中的PathUnity3D(171)
Application.persistentDataPath
Contains the path to a persistent data directory (Read Only).
设备中的公开目录,根据平台的不同而不同。这里面的文件不会因为App升级而删除;
Application.streamingAssetsPath
工程目录下面的Assets/StreamingAssets。
Application.temporaryCachePath
Contains the path to a temporary data / cache directory (Read Only).
设备的临时存储路径。
Application.dataPath
游戏数据的存储路径:
Contains the path to the game data folder (Read Only).
The value depends on which platform you are running on:
Unity Editor: &path to project folder&/Assets
Mac player: &path to player app bundle&/Contents
iPhone player: &path to player app bundle&/&AppName.app&/Data
Win player: &path to executablename_Data folder&
Web player: The absolute url to the player data file folder (without the actual data file name)
Flash: The absolute url to the player data file folder (without the actual data file name)
Note that the string returned on a PC will use a forward slash as a folder separator.
参考代码:
public static string GetStreamingFilePath( string filename)
string path = &&;
if ( Application.platform == RuntimePlatform .OSXEditor || Application.platform == RuntimePlatform .OSXPlayer ||
Application.platform == RuntimePlatform .WindowsEditor || Application.platform == RuntimePlatform .WindowsPlayer)
path = Application.dataPath + &/StreamingAssets/& +
else if ( Application.platform == RuntimePlatform .IPhonePlayer)
path = Application.dataPath + &/Raw/& +
else if ( Application.platform == RuntimePlatform .Android)
path = &jar:file://& + Application .dataPath + &!/assets/& +
path = Application.dataPath + &/config/& +
public static string GetPersistentFilePath( string filename)
if ( Application.platform == RuntimePlatform .OSXEditor || Application.platform == RuntimePlatform .OSXPlayer ||
Application.platform == RuntimePlatform .WindowsEditor || Application.platform == RuntimePlatform .WindowsPlayer)
filepath = Application.dataPath + &/StreamingAssets/& +
else if ( Application.platform == RuntimePlatform .IPhonePlayer || Application.platform == RuntimePlatform .Android)
filepath = Application.persistentDataPath + &/& +
filepath = Application.persistentDataPath + &/& +
#if UNITY_IPHONE
iPhone.SetNoBackupFlag(filepath);
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:312874次
积分:4912
积分:4912
排名:第4763名
原创:37篇
转载:890篇
评论:39条
(27)(26)(5)(2)(26)(8)(16)(25)(16)(27)(17)(40)(27)(13)(29)(57)(57)(86)(86)(60)(57)(40)(30)(54)(36)(11)(16)(3)(4)(9)(12)(17)当前位置: >
Unity中的Path对应各平台中的Path
时间: 09:58 来源:Unity之家 作者:unity.jb51.net 浏览:
最近使用unity读取各个平台路径,特别对移动平台路径的处理简直是各种蛋疼 各种坑在此与大家分享下:IOS:Application.dataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/DataApplication.streamingAssetsPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/RawApplication.persistentDataPath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/DocumentsApplication.temporaryCachePath : Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Library/CachesAndroid:Application.dataPath : /data/app/xxx.xxx.xxx.apkApplication.streamingAssetsPath : jar:file:///data/app/xxx.xxx.xxx.apk/!/assetsApplication.persistentDataPath : /data/data/xxx.xxx.xxx/filesApplication.temporaryCachePath : /data/data/xxx.xxx.xxx/cacheWindows Web Player:Application.dataPath : file:///D:/MyGame/WebPlayer (即导包后保存的文件夹,html文件所在文件夹)Application.streamingAssetsPath :Application.persistentDataPath :Application.temporaryCachePath :&注意:Application.persistentDataPath 才是移动端可用的保存生成文件的地方放到resource中打包后不可以更改了放到Application .dataPath中移动端是没有访问权限的
(责任编辑:脚印)
免责声明:Unity之家部分内容来源于互联网,如有侵权,请联系我们,本站将立即进行处理。
猜你也喜欢看这些 ??????
其他类型的Unity编程 ??????

我要回帖

更多关于 360云盘什么时候清空 的文章

 

随机推荐