Unity app安裝后的常用目錄
IOS:
- Application.dataPath : Application/xxxxx/xxx.app/Data
- Application.streamingAssetsPath : Application/xxxxx/xxx.app/Data/Raw
- Application.persistentDataPath : Application/xxxxx/Documents
- Application.temporaryCachePath : Application/xxxxx/Library/Caches
Android:
- 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
代碼輸出Application的信息
上面提到的目錄都是Application的靜態(tài)屬性琼开,還有很多環(huán)境屬性也在Application上膀估。
一個(gè)Debug輸出代碼密似,顯示所有Application的屬性值炭分。
private Vector2 _scroll_pos;
void OnGUI()
{
string s = "Application的靜態(tài)屬性:\n\n";
List<string> property_infos = new List<string>();
foreach (System.Reflection.PropertyInfo info in typeof(Application).GetProperties())
{
property_infos.Add(info.Name + " = " + info.GetValue(null, null));
}
property_infos.Sort();
s += String.Join("\n", property_infos.ToArray());
_scroll_pos = GUILayout.BeginScrollView(_scroll_pos);
GUI.skin.label.normal.textColor = Color.red;
GUILayout.Label(s);
GUILayout.EndScrollView();
}
Unity的資源數(shù)據(jù)加載
Resources
- 打包集成到.asset文件里面
- 主線(xiàn)程加載
- 想要?jiǎng)討B(tài)更新資源則不考慮
AssetBundle
- unity定義的二進(jìn)制文件類(lèi)型
- 用WWW類(lèi)下載
StreamingAssets
- 可讀不可寫(xiě)
- 內(nèi)容限制 - 無(wú)
- 只能用WWW類(lèi)下載
PersistentDataPath【安裝后才有這個(gè)目錄】
- 可讀可寫(xiě)
- 內(nèi)容限制 - 無(wú)
- 清除手機(jī)緩存文件會(huì)一并清理這里的東西
- 隨意弄,可作為本地目錄讓W(xué)WW下載乾忱、也可以自己用FileInfo亂整