public static void BuildAssetBundles() { BuildScript.BuildAssetBundles(BuildPanel.GetAssetBundleBuildList()); }
public static void CopyAssetBundlesToStreamingAssets() { BuildScript.CopyAssetBundlesTo(Path.Combine(Application.streamingAssetsPath, Helper.BundleSaveName)); AssetDatabase.Refresh(); }
public override void BuildOther() { if (!Directory.Exists(searchPath)) { Debug.LogWarning("Not exist " + searchPath); return; } var files = GetFilesWithoutPacked(searchPath, searchPattern, searchOption); // Collect dependencies. var commonAssets = new Dictionary <string, List <string> >(); for (var i = 0; i < files.Count; i++) { var item = files[i]; var dependencies = AssetDatabase.GetDependencies(item); if (EditorUtility.DisplayCancelableProgressBar($"Collecting... [{i}/{files.Count}]", item, i * 1f / files.Count)) { break; } foreach (var assetPath in dependencies) { if (!commonAssets.ContainsKey(assetPath)) { commonAssets[assetPath] = new List <string>(); } if (!commonAssets[assetPath].Contains(item)) { commonAssets[assetPath].Add(item); } } } // Generate AssetBundleBuild items. for (var i = 0; i < files.Count; i++) { var item = files[i]; if (EditorUtility.DisplayCancelableProgressBar($"Packing... [{i}/{files.Count}]", item, i * 1f / files.Count)) { break; } if (packedAssets.Contains(item.ToLower())) { continue; } var build = new AssetBundleBuild { assetBundleName = string.IsNullOrEmpty(bundleName) ? BuildScript.ConvertToBundleName(item) : bundleName, assetNames = new[] { item } }; builds.Add(build); packedAssets.Add(item.ToLower()); } // Pack the asset which is dependent by more than one asset in an AssetBundle along. foreach (var item in commonAssets) { var assetPath = item.Key; // Skip CS scripts. if (assetPath.EndsWith(".cs")) { continue; } // Skip the packed assets. if (packedAssets.Contains(assetPath.ToLower())) { continue; } // Pack the common assets. if (item.Value.Count > 1) { var build = new AssetBundleBuild { assetBundleName = BuildScript.ConvertToBundleName(assetPath, true), assetNames = new[] { assetPath } }; builds.Add(build); packedAssets.Add(assetPath.ToLower()); } } }