我已阅读AssetBundles Document,还尝试从特定的Intent googlePicker = AccountPicker.newChooseAccountIntent(null, null,
new String[] { GoogleAuthUtil.GOOGLE_ACCOUNT_TYPE }, null, null, null, null);
startActivityForResult(googlePicker, PICK_ACCOUNT_REQUEST);
中获取清单(如文档)。我想获取角色的清单,但是代码中的清单返回null。
我将第5行的assetbundle
更改为AssetBundleManifest
或character
,它也为空:
character.manifest
此图片是我的资产的文件夹:
PS。现在,我正在使用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;
}
。
答案 0 :(得分:1)
你已经接近解决它了。您必须在 AssetBundle.LoadFromFile
中加载的文件是文件 Android
,因此您的代码将如下所示:
private IEnumerator LoadAssetBundleManifest()
{
string assetBundlePath = Application.dataPath + "/../AssetBundles/Android/Android";
AssetBundle assetBundle = AssetBundle.LoadFromFile(assetBundlePath); // assetBundle also have data.
var manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
Hash128 characterHash = manifest.GetAssetBundleHash("character");
Debug.Log(characterHash.ToString()); //hash of the character AssetBundle
yield return null;
}
答案 1 :(得分:0)
您应该这样做
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);
}
答案 2 :(得分:0)
在加载AssetBundle清单
中阅读以下manual page加载AssetBundle清单 加载AssetBundle清单可能非常有用。尤其是在处理AssetBundle依赖项时。
要获取可用的AssetBundleManifest对象,您需要加载该其他AssetBundle(与所在文件夹名称相同的对象),并从中加载一个AssetBundleManifest类型的对象。
加载清单本身的过程与从AssetBundle中的任何其他资产完全相同:
AssetBundle assetBundle = AssetBundle.LoadFromFile(manifestFilePath); AssetBundleManifest manifest = assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
现在,您可以通过上述示例中的清单对象访问AssetBundleManifest API调用。在这里,您可以使用清单来获取有关所构建的AssetBundle的信息。该信息包括AssetBundle的依赖项数据,哈希数据和变体数据。
根据上面的显示,您正在传递错误的清单文件, 您应该通过Android asstbundle,而不要通过。