Unity AssetBundle 載入
1.根據打包的manifes檔案載入所有assetbundle包
C#
// 下載所有assetbundle包
Ienumerator DownLoadMainAssetBundle()
{
UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(mainAssetBundleURL);
yield return request.SendWebRequest();
AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(request);
AssetBundleManifest manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
string[] names = manifest.GetAllAssetBundles();
for(int i=0;i<names.Length;i++)
{
StartCoroutine(DownLoadAssetBundleAndSave(allAssetBundleURL+name[i]));
}
}
IEnumerator DownLoadAssetBundleAndSave(string url)
{
WWW www = new WWW(url);
yield return www;
if(www.isDone)
{
SaveAssetBundle(Path.GetFileName(url),www.bytes,www.bytes.Length);
}
}
private void SaveAssetBundle(string fileName,byte[] bytes,int count)
{
FileInfo fileInfo = new FileInfo(Application.streamingAssetsPath+"//"+fileName);
FileStream fs = fileInfo.Create();
fs.Write(bytes,0,count);
fs.Flush();
fs.Close();
fs.Dispose();
Debug.Log("下載完畢");
}
IEnumerator DownLoadSingleAssetBundle(string url)
{
UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(url);
yield return request.SendWebRequest();
AssetBundle assetBundle = DownloadHandlerAssetBundle.GetContent(request);
string[] names = assetBundle.GetAllAssetNames();
for(int i=0;i<names.Length;i++)
{
string tempName = Path.GetFileNameWithoutExtension(names[i]);
GameObject obj = assetBundle.LoadAsset<GameObject>(tempName);
Instantiate(obj);
}
}
相關文章
- unity3D AssetBundle載入方式Unity3D
- [Unity] 實現AssetBundle資源載入管理器Unity
- Unity AssetBundle(2):工具UnityStudioUnity
- Unity——AssetBundle打包工具Unity
- Unity 熱更--AssetBundle學習筆記 1.0【AB包資源載入工具類的實現】Unity筆記
- Unity C# 打包AssetBundle與場景UnityC#
- Unity 熱更--AssetBundle學習筆記 0.7Unity筆記
- Unity 熱更--AssetBundle學習筆記 0.8Unity筆記
- Unity AssetBundle,Asset,GameObject之間的聯絡UnityGAMObject
- Unity5.5 AssetBundle用法-面向Android平臺(1)UnityAndroid
- Unity5 AssetBundle的一些整理(一)Unity
- 【Unity遊戲開發】SpriteAtlas與AssetBundle最佳食用方案Unity遊戲開發
- Unity GameFramework丨(二十三)使用 AssetBundle 編輯工具UnityGAMFramework
- Unity3D動態載入FBX檔案Unity3D
- 細談unity資源載入和解除安裝Unity
- Unity大密度建築場景載入解決方案Unity
- AssetBundle上層框架框架
- 基於Unity3D引擎的大地形載入研究Unity3D
- Unity匯入xLua流程Unity
- 常用的Unity輸入方法Unity
- Unity之掛載小問題Unity
- Unity射線(轉載存檔)Unity
- unity場景匯入iOSAPP求助UnityiOSAPP
- Unity學習筆記--入門Unity筆記
- Unity熱更學習toLua使用--[1]toLua的匯入和預設載入執行lua指令碼Unity指令碼
- unity入門—資源匯入與場景建立Unity
- Unity Shader 入門精要 筆記(1)Unity筆記
- Unity開發實戰探討-資源的載入釋放最佳策略簡要心得Unity
- unity案例入門(拾取遊戲)Unity遊戲
- AssetBundle在移動裝置上丟失
- 熱更新基礎--AssetBundle學習筆記筆記
- Unity3D開發入門教程(二)—— Lua入門Unity3D
- 懶載入和預載入
- unity遊戲開發雜項系列:unity在商店裡下載的package儲存位置Unity遊戲開發Package
- Unity使用DOTween實現金幣飛入效果Unity
- 知物由學 | iOS AssetBundle資源保護iOS
- 類載入-載入時機學習
- 圖片預載入和懶載入