01.程序集
程序集引入
02.
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;
public class AssetBundleEditor : MonoBehaviour
{
[MenuItem("Tools/打包")]
public static void Buid()
{
if (Directory.Exists(Application.streamingAssetsPath) == false)
{
Directory.CreateDirectory(Application.streamingAssetsPath);
}
BuildPipeline.BuildAssetBundles(Application.streamingAssetsPath, BuildAssetBundleOptions.ChunkBasedCompression,
EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh();
}
}
void Start()
{
AssetBundle assetBundle=AssetBundle.LoadFromFile(Application.streamingAssetsPath + "/Attack");
GameObject item=Instantiate(assetBundle.LoadAsset<GameObject>("Attack"));
item.transform.SetParent(this.transform);
}