Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public AssetBundle ReturnAssetBundle()
- {
- //Loads current bundle
- if (NetworkSceneLoader.loadedBundles.Where(x => x.name == assetBundleName).Count() == 0)
- {
- string currentURL = DOWNLOAD_LINK_TEMPLATE + assetBundleDownloadID;
- string localPath = FileHelper.SetDirectory(LOCAL_PATH);
- if(localPath == null)
- {
- Debug.LogError("Local Path could not be set!");
- return null;
- }
- string currentPath = Path.Combine(localPath, assetBundleName + BUNDLE_SUFFIX);
- //Instantiating a WebClient used to download the needed file
- WebClient webClient = new WebClient();
- webClient.DownloadFile(currentURL, currentPath);
- //Disposing the WebClient in order to lower memory usage
- webClient.Dispose();
- assetBundle = AssetBundle.LoadFromFile(currentPath);
- if (assetBundle == null)
- {
- Debug.LogError("Asset Bundle could not be loaded!");
- return null;
- }
- return assetBundle;
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement