unity3D AssetBundle載入方式
首先在Editor資料夾下建立快捷打包的方式
[MenuItem(“AssetBuiled/Build”)]
static void EditorWindow()
{
string path = “AssetBundle”;
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
BuildPipeline.BuildAssetBundles(path, BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
}
如果需要在安卓端的話 修改下 方法中的BuildTarget
把預製體和材質球設定為下圖格式 然後點選視窗下的AssetBuiled中的Build**
這是載入後的效果 一個cube和對應的材質球
預製體和對應材質球設定 把他們放置在同一個資料夾CC下
blog.csdnimg.cn/20181119173144714.)這裡插入圖片描述](https://img-blog.csdnimg.cn/20181119173025865.?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2x5YjE5OTQwNTI2,size_16,color_FFFFFF,t_70)
void Start()
{
//1.從本地載入
AssetBundle assetBundle = AssetBundle.LoadFromFile(“AssetBundle/cc/cube”);
GameObject cube = assetBundle.LoadAsset(“cube”);
Instantiate(cube);
AssetBundle AB = AssetBundle.LoadFromFile(“AssetBundle/AssetBundle”);
AssetBundleManifest manifset = AB.LoadAsset(“AssetBundleManifest”);
string[] manifsetAB = manifset.GetAllDependencies(“cc/cube”);
foreach (var item in manifsetAB)
{
//獲取到cube所有的依賴項後給載入出來
AssetBundle.LoadFromFile(“AssetBundle/” + item);
}
}加粗樣式
IEnumerator Start()
{
#region 從記憶體載入
AssetBundleCreateRequest asset = AssetBundle.LoadFromFileAsync(@“C:\Users\Administrator\Desktop\鬥地主\單機版\assetBuild\AssetBundle\cc\cube”);
yield return asset;
AssetBundle assetBundle = asset.assetBundle;
GameObject cube = assetBundle.LoadAsset(“Cube”);
Instantiate(cube);
AssetBundle AB = AssetBundle.LoadFromFile(“AssetBundle/AssetBundle”);
AssetBundleManifest manifset = AB.LoadAsset(“AssetBundleManifest”);
string[] manifsetAB = manifset.GetAllDependencies(“cc/cube”);
foreach (var item in manifsetAB)
{
//獲取到cube所有的依賴項後給載入出來
AssetBundle.LoadFromFile(“AssetBundle/” + item);
}
#endregion
#region 用WWW類載入
//WWW a = new WWW(@“http://192.168.201.35/AssetBundle/cc/cube”);
//yield return a;
//AssetBundle asset = a.assetBundle;
//GameObject cube = asset.LoadAsset(“Cube”);
//Instantiate(cube);
//AssetBundle ab = AssetBundle.LoadFromFile(“AssetBundle/AssetBundle”);
//AssetBundleManifest bundleManifest = ab.LoadAsset(“AssetBundleManifest”);
//string[] all = bundleManifest.GetAllDependencies(“cc/cube”);
//foreach (var item in all)
//{
// AssetBundle.LoadFromFile(“AssetBundle/” + item);
//}
#endregion
#region 從伺服器載入
//UnityWebRequest request = UnityWebRequest.GetAssetBundle(@“http://192.168.201.35/AssetBundle/cc/cube”);
//yield return request.Send();
//AssetBundle asset = (request.downloadHandler as DownloadHandlerAssetBundle).assetBundle;
//GameObject cube = asset.LoadAsset(“cube”);
//Instantiate(cube);
//AssetBundle AB = AssetBundle.LoadFromFile(“AssetBundle/AssetBundle”);
//AssetBundleManifest manifset = AB.LoadAsset(“AssetBundleManifest”);
//string[] manifsetAB = manifset.GetAllDependencies(“cc/cube”);
//foreach (var item in manifsetAB)
//{
// //獲取到cube所有的依賴項後給載入出來
// AssetBundle.LoadFromFile(“AssetBundle/” + item);
//}
#endregion
}
目前不太懂伺服器的相關知識,後兩種只是一個小的嘗試
相關文章
- Unity3d熱更新全書-載入(一)從AssetBundle說起Unity3D
- Unity AssetBundle 載入Unity
- Unity3D高階-AssetBundle使用Unity3D
- Unity3d熱更新全書-載入(二)如何在不用AssetBundle的前提下動態載入預設Unity3D
- [Unity] 實現AssetBundle資源載入管理器Unity
- 多重載入Bean方式Bean
- 載入圖片方式
- Unity3D動態載入FBX檔案Unity3D
- JavaScript 檔案載入方式JavaScript
- 基於Unity3D引擎的大地形載入研究Unity3D
- 使用sqlloader的直接載入方式和傳統載入方式的效能差異SQL
- Unity3D入門Unity3D
- Unity3d 入門(一) 瞭解Unity3dUnity3D
- 關於angularjs的載入方式AngularJS
- Vue中圖片的載入方式Vue
- 現代化懶載入的方式
- OpenSSL Engine的三種載入方式
- 小說APP原始碼的圖片載入方式,懶載入和預載入的實現APP原始碼
- Unity 熱更--AssetBundle學習筆記 1.0【AB包資源載入工具類的實現】Unity筆記
- spring bean定義與載入方式SpringBean
- Python頁面載入的等待方式Python
- 不一樣的圖片載入方式
- spring 載入配置檔案的方式Spring
- iOS彈幕高效載入實現方式iOS
- View的載入原理和攔截方式View
- js延遲載入的方式有哪些?JS
- SMSSDK的Unity3D的兩種整合方式Unity3D
- 【原創】比較使用sql*loader的直接載入方式和傳統載入方式的效能差異SQL
- AssetBundle上層框架框架
- tensorflow載入資料的三種方式
- 谷歌:如何以最高效的方式載入 WebAssembly谷歌Web
- unity3d下載Obb分包檔案Unity3D
- Unity3D ogg下載並播放Unity3D
- Unity——AssetBundle打包工具Unity
- AssetBundle打包學習(三)
- HBase協處理器載入的三種方式
- 實現圖片懶載入的三種方式
- SMSSDK的Unity3D的兩種整合方式-AndroidUnity3DAndroid