问题
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.
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. Now, I'm using Unity 2018.1.1f1
.
回答1:
you should do like this
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);
}
来源:https://stackoverflow.com/questions/51280401/how-to-get-assetbundlemanifest-from-assetbundle-in-unity3d