SHARE
TWEET

Untitled

a guest Oct 21st, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public AssetBundle ReturnAssetBundle()
  2.     {
  3.         //Loads current bundle
  4.         if (NetworkSceneLoader.loadedBundles.Where(x => x.name == assetBundleName).Count() == 0)
  5.         {
  6.             string currentURL = DOWNLOAD_LINK_TEMPLATE + assetBundleDownloadID;
  7.             string localPath = FileHelper.SetDirectory(LOCAL_PATH);
  8.  
  9.             if(localPath == null)
  10.             {
  11.                 Debug.LogError("Local Path could not be set!");
  12.  
  13.                 return null;
  14.             }
  15.  
  16.             string currentPath = Path.Combine(localPath, assetBundleName + BUNDLE_SUFFIX);
  17.  
  18.             //Instantiating a WebClient used to download the needed file
  19.             WebClient webClient = new WebClient();
  20.  
  21.             webClient.DownloadFile(currentURL, currentPath);
  22.  
  23.             //Disposing the WebClient in order to lower memory usage
  24.             webClient.Dispose();
  25.  
  26.             assetBundle = AssetBundle.LoadFromFile(currentPath);
  27.  
  28.             if (assetBundle == null)
  29.             {
  30.                 Debug.LogError("Asset Bundle could not be loaded!");
  31.  
  32.                 return null;
  33.             }
  34.  
  35.             return assetBundle;
  36.         }
  37.         return null;
  38.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top