static async void LoadManifest() { var bundleName = BundleUtility.GetPlatformName(); Debug.Log("Loading Asset Bundle Manifest: " + bundleName); var bundle = await LoadAssetBundleRaw(bundleName); var loadedBundle = new LoadedAssetBundle(new BundleMetadata(bundleName), bundle); var task = new TaskCompletionSource <LoadedAssetBundle>(loadedBundle); AssetBundles.Add(bundleName, task); var request = await bundle.LoadAssetAsync <AssetBundleManifest>("AssetBundleManifest").ToTask(); Manifest.SetResult(new BundleManfiestMap(request.asset as AssetBundleManifest)); }
static async Task <AssetBundle> LoadAssetBundleRaw(string assetBundleName) { const int kTimeout = 20000; var path = BundleUtility.GetLocalBundlePath(assetBundleName); var loadTask = AssetBundle.LoadFromFileAsync(path).ToTask(); if (await Task.WhenAny(loadTask, Task.Delay(kTimeout)) == loadTask) { return(loadTask.Result.assetBundle); } else { Debug.LogError($"Asset Bundle Load timed out. Bundle Name: {assetBundleName}. Timeout: {kTimeout}"); throw new Exception($"Asset Bundle Load timed out. Bundle Name: {assetBundleName}. Timeout: {kTimeout}"); } }
public static void BuildAssetBundles(BuildTarget?target = null) { var buildTarget = target ?? EditorUserBuildSettings.activeBuildTarget; // Choose the output path according to the build target. string outputPath = Path.Combine(BundleUtility.AssetBundlesOutputPath, BundleUtility.GetPlatformName(target)); if (!Directory.Exists(outputPath)) { Directory.CreateDirectory(outputPath); } //@TODO: use append hash... (Make sure pipeline works correctly with it.) BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.ChunkBasedCompression | BuildAssetBundleOptions.DeterministicAssetBundle | BuildAssetBundleOptions.StrictMode, buildTarget); CopyAssetBundlesTo(outputPath, Path.Combine(Application.streamingAssetsPath, BundleUtility.AssetBundlesOutputPath)); AssetDatabase.Refresh(); }
public static void BuildPlayer() { var outputPath = EditorUtility.SaveFolderPanel("Choose Location of the Built Game", "", ""); if (outputPath.Length == 0) { return; } string[] levels = GetLevelsFromBuildSettings(); if (levels.Length == 0) { Debug.Log("Nothing to build."); return; } var target = EditorUserBuildSettings.activeBuildTarget; string targetName = GetBuildTargetName(target); if (targetName == null) { return; } // Build and copy AssetBundles. BuildAssetBundles(); CopyAssetBundlesTo(Path.Combine(BundleUtility.AssetBundlesOutputPath, BundleUtility.GetPlatformName(target)), Path.Combine(Application.streamingAssetsPath, BundleUtility.AssetBundlesOutputPath)); AssetDatabase.Refresh(); BuildOptions option = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None; BuildPipeline.BuildPlayer(levels, outputPath + targetName, EditorUserBuildSettings.activeBuildTarget, option); if (Directory.Exists(outputPath)) { foreach (var file in Directory.GetFiles(outputPath, "*.manifest", SearchOption.AllDirectories)) { File.Delete(file); } } }
public static void SetSourceAssetBundleUrl(string absolutePath) { BaseDownloadingUrl = absolutePath + BundleUtility.GetPlatformName() + "/"; }
public static bool IsValidLocalBundle(string path) { return(File.Exists(BundleUtility.GetLocalBundlePath(path))); }