dv_locofaces/BundleBuilder/Assets/Scripts/BundleBuilder.cs

45 lines
1.0 KiB
C#

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<AssetBundleBuild>();
var asssetBundleFiles = new List<string>();
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