- Choose prefab
- See bottom of inspector
- Set AssetBundle name
- Create Assets/Editor/ExportAssetBundles.cs
- Choose menu -> Assets -> Unity 5.x Build AssetBundle
- Generate file into StreamingAssets folder
ExportAssetBundles.cs
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
public class ExportAssetBundles : MonoBehaviour
{
[MenuItem("Assets/Unity 5.x Build AssetBundle")]
static void ExportResource_Unity5()
{
Debug.Log("Target=" + EditorUserBuildSettings.activeBuildTarget.ToString());
// Folder name is PlatForm name
string OutPutPath = Application.streamingAssetsPath + "/" + EditorUserBuildSettings.activeBuildTarget.ToString();
if (Directory.Exists(OutPutPath) == false )
{
Directory.CreateDirectory(OutPutPath);
}
// Build AssetBundle at platform manifest.
BuildPipeline.BuildAssetBundles(OutPutPath, 0, EditorUserBuildSettings.activeBuildTarget);
Debug.Log("ComPress End");
}
}