##资源路径
iOS:
Application.dataPath /var/containers/Bundle/Application/app sandbox/xxx.app/Data
Application.streamingAssetsPath /var/containers/Bundle/Application/app sandbox/test.app/Data/Raw
Application.temporaryCachePath /var/mobile/Containers/Data/Application/app sandbox/Library/Caches
Application.persistentDataPath /var/mobile/Containers/Data/Application/app sandbox/Documents
Android:
Application.dataPath /data/app/package name-1/base.apk
Application.streamingAssetsPath jar:file:///data/app/package name-1/base.apk!/assets
Application.temporaryCachePath /storage/emulated/0/Android/data/package name/cache
Application.persistentDataPath /storage/emulated/0/Android/data/package name/files
Windows:
Application.dataPath appname_Data/
Application.streamingAssetsPath appname_Data/StreamingAssets
Application.temporaryCachePath C:\Users\username\AppData\Local\Temp\company name\product name
Application.persistentDataPath C:\Users\username\AppData\LocalLow\company name\product name
##资源载入
###1.IO方式
using(FileStream fs = FIle.Open(Application.streamingAssetsPath + "fileName",FileMode.Open)){
//do something
}
###2.WWW方式
方式1
using(WWW www = new WWW(Application.streamingAssetsPath + "fileName")){
yield return www;
//do something
}
方式2
WWWW www = new WWW(Application.streamingAssetsPath + "fileName");
try{
yield return www;
//do something
}finally{
www.Dispose();
}
###3.AssetBundle方式
string abPath =
#if UNITY_ANDROID
Application.dataPath + "!assets";
#else
Application.streamingAssetsPath;
#endif
AssetBundle.LoadFromFile(abPath + "/fileName.unity3d");
####1.Assets
AssetDatabase.LoadAssetAtPath("Assets/../sun.png");
只能在编辑器下获取资源对象。
####2.Resources
Resources.Load("/../fileName");
同名资源,只会返回第一个符合名字的资源对象。
Resources.LoadAll("/../fileName");
返回所有符合的资源对象。
####3.PresistentDataPath
可读写外部文件夹,不会被打入包中,只能WWW/IO加载。
####4.StreamingAssets
原封不动打入包中,只能WWW/IO加载(AssetBundle除外)。