本文介绍了如何从Unity3D中的AssetBundle获取AssetBundleManifest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已阅读 AssetBundles文档,并且还尝试从中获取清单具体的assetbundle
类似于文档.我想获取角色的清单,但是代码中的清单返回null.
I have read AssetBundles Document and also tried to get the manifest from the specific assetbundle
like the document. I want to get character's manifest but the manifest from the code returns null.
我将第5行的AssetBundleManifest
更改为character
或character.manifest
,并且它也是空的:
I've changed the AssetBundleManifest
at line 5 to character
or character.manifest
and it is also null:
private IEnumerator LoadAssetBundleManifest()
{
string assetBundlePath = Application.dataPath + "/../AssetBundles/Android/character";
AssetBundle assetBundle = AssetBundle.LoadFromFile(assetBundlePath); // assetBundle also have data.
var manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
print(manifest); // manifest = null
yield return null;
}
此图片是我的资产的文件夹:
This image is the folder of my asset:
PS.现在,我正在使用Unity 2018.1.1f1
.
PS. Now, I'm using Unity 2018.1.1f1
.
推荐答案
您应该这样做
void LoadAsserBundle()
{
AssetBundle manifestAssetBundle = AssetBundle.LoadFromFile(GetAssetBundlePath("StreamingAssets"));
AssetBundleManifest assetBundleManifest = manifestAssetBundle.LoadAsset<AssetBundleManifest>("assetbundlemanifest");
AssetBundle assetBundle = AssetBundle.LoadFromFile(GetAssetBundlePath("character"));
Hash128 hash = assetBundleManifest.GetAssetBundleHash(assetBundle.name);
}
这篇关于如何从Unity3D中的AssetBundle获取AssetBundleManifest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!