How to know asset load from cache or remote? Unity 2019
Hello everyone, I am new to Asset Bundle and try to load the asset bundle. Currently, I can remote load asset from server, but I am a bit confused.
From doc: https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequestAssetBundle.GetAssetBundle.html It mentions that by using version number or Hash128 Unitywebrequest will use caching system to load from remote or from cache. Then, how to know that the assetbundle has been loaded from remote or cache one?
Here is my code. What I have to add to know where the asset has been loaded from?
IEnumerator DownloadAssetBundle()
{
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle("https://www.dropbox.com/s/jw71zlw6rgf7bcz/AssetBundles?dl=1",1,0);
yield return www.SendWebRequest();
if(www.isNetworkError || www.isHttpError) {
Debug.Log(www.error);
}
else {
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(www);
AssetBundleManifest manifest = bundle.LoadAsset<AssetBundleManifest>("AssetBundles");
Instantiate(bundle.LoadAsset("RayBan_Sunglasses"));
}
}
And also, when I tried to get Hash128, it always return null. What I have missed? The assetbundle file I have is named "testasset".
Answer by fantatik3 · May 23 at 01:51 PM
Kinda late to reply but well maybe someone else wondering about this... :D
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest-responseCode.html