您的位置:首页 > 移动开发

Application路径

2016-07-19 14:48 323 查看
根目录: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.xml;

#endif

根目录:Resources 文件夹

可以使用Resources.Load("名字"); 把文件夹中的对象加载出来

根目录:StreamingAssets 文件夹

可以使用Application.dataPath进行读操作

Application.dataPath: 只可读不可写,放置一些资源数据

Application.persistentDataPath

iOSAndroid平台都可以使用这个目录下进行读写操作,可以存放各种配置文件进行修改之类的。

在PC上的地址是:C:\Users\用户名 \AppData\LocalLow\DefaultCompany\test


Application.dataPath : 数据路径

Unity Editor: <path tp project folder>/Assets

Unity 编辑器:<工程文件夹的路径>/Assets 

Mac player: <path to player app bundle>/Contents
Mac播放器:<到播放器应用的路径>/Contents 

iPhone player: <path
to player app bundle>/<AppName.app>/Data
iPhone播放器:<到播放器应用的路径>/<AppName.app>/Data 

Win player: <path to executablename_Data folder>
Win播放器:< 包含可执行播发器的文件夹的路径>\Data 

Dashboard widget: <path to the dashboard widget bundle>
Dasboard窗口:< dashboard widget bundle的路径> 

Web player: The absolute url to the player data file folder (without
the actual data file name)
网络播放器:到播放器数据文件夹的绝对路径(没有实际的数据文件名称)


重要路径之 之Resources

• Resources文件夹下的资源无论使用与否都会被打包

• 资源会被压缩,转化成二进制

• 打包后文件夹下的资源只读

• 无法动态更改,无法做热更新

• 使用Resources.Load加载

 


重要路径之StreamingAssets

• 流数据的缓存目录

• 文件夹下的资源无论使用与否都会被打包

• 资源不会被压缩和加密

• 打包后文件夹下的资源只读,主要存放二进制文件

• 无法做热更新

• WWW类加载(一般用CreateFromFile ,若资源是AssetBundle,依据其打包方式看是否是压缩的来决定)

• 相对路径,具体路径依赖于实际平台

•Application.streamingAssetsPath

• IOS: Application.dataPath + “/Raw” 或Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data/Raw

 


重要路径之Application.dataPath

• 游戏的数据文件夹的路径(例如在Editor中的Assets)

• 很少用到

• 无法做热更新

• IOS路径: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/xxx.app/Data


重要路径之Application.persistentDataPath

• 持久化数据存储目录的路径( 沙盒目录,打包之前不存在 )

• 文件夹下的资源无论使用与否都会被打包

• 运行时有效,可读写

• 无内容限制,从StreamingAsset中读取二进制文件或从AssetBundle读取文件来写入PersistentDataPath中

• 适合热更新

• IOS路径: Application/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/Documents
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: