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
- Unity3d熱更新全書-載入(一)從AssetBundle說起Unity3D
- Unity——AssetBundle打包工具Unity
- Unity AssetBundle(2):工具UnityStudioUnity
- Unity3d熱更新全書-載入(二)如何在不用AssetBundle的前提下動態載入預設Unity3D
- Unity 熱更--AssetBundle學習筆記 1.0【AB包資源載入工具類的實現】Unity筆記
- Unity C# 打包AssetBundle與場景UnityC#
- Unity3D高階-AssetBundle使用Unity3D
- Unity AssetBundle,Asset,GameObject之間的聯絡UnityGAMObject
- Unity 熱更--AssetBundle學習筆記 0.7Unity筆記
- Unity 熱更--AssetBundle學習筆記 0.8Unity筆記
- Unity5 AssetBundle的一些整理(一)Unity
- Unity5.5 AssetBundle用法-面向Android平臺(1)UnityAndroid
- 【Unity遊戲開發】SpriteAtlas與AssetBundle最佳食用方案Unity遊戲開發
- Unity GameFramework丨(二十三)使用 AssetBundle 編輯工具UnityGAMFramework
- [Unity-24] Unity的四種載入場景的方法Unity
- Unity載入模組深度解析(網格篇)Unity
- 細談unity資源載入和解除安裝Unity
- Unity實現子目錄下的Plugins載入UnityPlugin
- Unity大密度建築場景載入解決方案Unity
- Unity3D動態載入FBX檔案Unity3D
- 基於Unity3D引擎的大地形載入研究Unity3D
- AssetBundle上層框架框架
- Unity匯入xLua流程Unity
- cardboard sdk for unity 下載地址Unity
- AssetBundle打包學習(三)
- unity之入門經驗Unity
- Unity3D入門Unity3D
- 常用的Unity輸入方法Unity
- Unity之掛載小問題Unity
- Unity射線(轉載存檔)Unity
- Unity3d 入門(一) 瞭解Unity3dUnity3D
- Unity學習筆記--入門Unity筆記
- Unity熱更學習toLua使用--[1]toLua的匯入和預設載入執行lua指令碼Unity指令碼
- unity入門—資源匯入與場景建立Unity
- unity案例入門(拾取遊戲)Unity遊戲
- Android Unity Plugin 開發指南(轉載)AndroidUnityPlugin