01.程序集和资源加载
原创
©著作权归作者所有:来自51CTO博客作者我的流浪国的原创作品,请联系作者获取转载授权,否则将追究法律责任
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);
}