Unity AssetBundle的幾個載入方式

2022-08-31 01:54:12 字數 1469 閱讀 4437

//第一種載入ab的方式,非同步進行載入從二進位制檔案中

ienumerator loadab()

//第二種進行資源載入,同步載入

instantiate(assetbundle.loadfrommemory(file.readallbytes(path)).loadasset("cubewall"));

//第三種載入ab的方式,loadfromfile【從檔案進行載入】

assetbundle ab = assetbundle.loadfromfile("assetbundles/scene/wall.ab");

gameobject wallprefab = ab.loadasset("wall");

instantiate(wallprefab);

//第四種載入ab的方式,loadfromfileasync【從檔案進行非同步載入】

ienumerator loadfileasync()

ienumerator loadcacheordownloadfromfile(string path)

assetbundle ab = www.assetbundle;

gameobject wallprefab = ab.loadasset("cubewall");

instantiate(wallprefab);

}//第六種載入ab的方式,unitywebrequest,網頁請求進行載入【第一種方法】

ienumerator useunitywebrequest(string path)

//第六種載入ab的方式,unitywebrequest,網頁請求進行載入【第二種方法】

ienumerator useunitywebrequest2(string path)

讀取manifest檔案,獲取它們的依賴關係並且載入出來

assetbundle manifestab = assetbundle.loadfromfile("assetbundles/assetbundles");

assetbundlemanifest manifest = manifestab.loadasset("assetbundlemanifest");

string strarr = manifest.getalldependencies("scene/cubewall.ab");

foreach (var item in strarr)

【待繼續往後寫】

Unity AssetBundle的幾個載入方式

第一種載入ab的方式,非同步進行載入從二進位制檔案中 ienumerator loadab 第二種進行資源載入,同步載入 instantiate assetbundle.loadfrommemory file.readallbytes path loadasset cubewall 第三種載入ab的...

Unity AssetBundle的壓縮方式

unity支援 三種assetbundle打包的壓縮方式 lzma,lz4,以及不壓縮。1 lzma壓縮方式 buildassetbundleoptions.none 是一種預設的壓縮形式,這種標準壓縮格式是乙個單一lzma流序列化資料檔案,並且在使用前需要解壓縮整個包體。lzma壓縮是比較流行的壓...

iPhone OpenGL ES載入紋理的方法

載入一張名為xiezi.png的紋理 void loadtexture nsinteger texwidth cgimagegetwidth textureimage nsinteger texheight cgimagegetheight textureimage glubyte textured...