How to create Asset Bundles in Unity by script

I think the only way to make an Asset Bundle in Unity is by using script, this one is taken from Unity official tutorial.

Have a folder named Editor in your Assets folder, and make this script inside it:

using UnityEngine;
using UnityEditor;
using System.IO;

public class CreateAssetBundles
	[MenuItem("Assets/Build AssetBundles")]
	static void BuildAllAssetBundles()
  	string assetBundleDirectory = "Assets/StreamingAssets";
  	if (!Directory.Exists(Application.streamingAssetsPath))
  	BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);

Name the file CreateAssetBundles.cs

And then, I think I better show it to you in this video…


Leave a Reply

Your email address will not be published.