I am newbie in AssetBundle and try to learn about this. Currently, I can load the asset from the server, but I cannot get hash from the asset file itself. It's keeping return NullException.
I have tried follow the doc here: https://docs.unity3d.com/ScriptReference/Caching.html
But still have no idea, and get the NullException at Hash too.
Found this as well and no luck: How to get AssetBundleManifest from AssetBundle in Unity3D
Then I tried follow the instruction in this post: Get Hash128 from AssetBundle for the Caching.IsVersionCached function
But still get NullException()
Here is the code I follow the latest link:
IEnumerator DownloadAssetBundle()
{
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle("https://www.dropbox.com/s/66psd4aphlgpo2j/testasset?dl=1");
yield return www.SendWebRequest();
if(www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
AssetBundleRequest asset = bundle.LoadAssetAsync<AssetBundleManifest>("assetManifestName");
yield return asset;
//Get the AssetBundleManifest
AssetBundleManifest loadedAssetMf = asset.asset as AssetBundleManifest;
//Get Hash128 from the AssetBundleManifest
Hash128 tempHash128 = loadedAssetMf.GetAssetBundleHash("");
//Pass to the IsVersionCached function
Caching.IsVersionCached("https://www.dropbox.com/s/66psd4aphlgpo2j/testasset?dl=1", tempHash128);
//Instantiate(bundle.LoadAsset("RayBan_Sunglasses"));
}
}
Could anyone explain how to get the Hash from assetBundle
what I have done wrong?
The file name of my Asset Bundle is "testasset"
If you please, specify where to put the "testasset"
, it would be a pleasure. Thank you so much for every answer.