using System.Collections; using System.Collections.Generic; using UnityEditor; using UnityEngine; #if UNITY_EDITOR public class BundleBuilder : MonoBehaviour { public string bundleName; public string exportPath; public void BuildIt() { var builds = new List(); var asssetBundleFiles = new List(); foreach (var assPath in AssetDatabase.GetAllAssetPaths()) { if (!assPath.StartsWith("Assets/ToBuild")) { continue; } asssetBundleFiles.Add(assPath); } builds.Add(new AssetBundleBuild { assetBundleName = bundleName, assetNames = asssetBundleFiles.ToArray() }); bool success = BuildPipeline.BuildAssetBundles( exportPath, builds.ToArray(), BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64 ); Debug.Log($"success: {success}"); } } #endif