0

I use the following code to download my asset bundle from a server.

  1. If I run this code for a second time after a restart for my app, will it redownload the bundle or not because it's in the cache? and how will I know if it's redownloading / not downloading
  2. I read about hash and version number- how would you change this code to verify the hash and version number
  3. Do I need to keep the manifest file? When building asset bundles I get 2 files, one is the assets and another is the manifset. I upload only the assets (big file) to my server and ignore the manifest, which works fine, but in that case does it mean I can't use caching? The reason I only upload one file is because UnityWebRequestAssetBundle downloads one file.

Build asset bundle-

static void BuildABs()
{
BuildPipeline.BuildAssetBundles("Assets/abs", BuildAssetBundleOptions.ChunkBasedCompression, 
BuildTarget.iOS);
}

Load Asset Bundle

using (UnityWebRequest uwr = UnityWebRequestAssetBundle.GetAssetBundle(url))
{
yield return uwr.SendWebRequest();

if (uwr.isNetworkError || uwr.isHttpError)
{
Debug.Log(uwr.error);
}
else
{
// Get downloaded asset bundle
myLoadedAssetBundle = DownloadHandlerAssetBundle.GetContent(uwr);
}
SHAI
  • 789
  • 3
  • 10
  • 43
  • Please limit your questions to **one** at a time. Currently your question is to broad. In general: if you start a `UnityWebRequest` it will download whatever again .. it is an HTTP request that doesn't have information about what it is going to download. If you want to use caching rather store your file local on the device and check if it already exists before downloading.. – derHugo Feb 17 '20 at 06:49

1 Answers1

0
  1. inorder to force cashing using UnityWebRequest you need to pass a hashcode or CRC along with the URI as a prameter to UnityWebRequest which can be found at the Asset bundle manifest of the platform you built the assetbundle to as per this Manual Page you well find the code snippets to do so.
  2. see this answer.
  3. read the manual page at 1 to understand how manual works and which manual exactly do you need.
XRDevMK
  • 1
  • 2