//先批量创建配置Prefab,方便AB包加载后导入场景
private void CreatePrefab(GameObject obj, string path)
{
PrefabUtility.CreatePrefab(path + "/" + obj.name + ".prefab", obj, ReplacePrefabOptions.ConnectToPrefab);
AssetDatabase.SaveAssets();
}
//清理所有AssetBundle名字
private void ClearAssetBundleName()
{
foreach (var abName in AssetDatabase.GetAllAssetBundleNames())
{
AssetDatabase.RemoveAssetBundleName(abName, true);
}
AssetDatabase.RemoveUnusedAssetBundleNames();
}
//设置路径下打包文件AssetBundle名和后缀
private void SetAssetImport(string Assetpath)
{
//获取路径下所有文件及子目录路径
var paths = Directory.GetFileSystemEntries(Assetpath);
//遍历筛选导入
foreach (var path in paths )
{
if (Path.GetExtension(path) != ".meta")
{
var assetImportPath = path.Replace("\\", "/");
var assetImport = AssetImporter.GetAtPath(assetImportPath);
assetImport.assetBundleName = AssetDatabase.LoadAssetAtPath<Object>(assetImportPath).name;
assetImport.assetBundleVariant = "bundle";
}
}
}
BuildPipeline.BuildAssetBundles(outputPath, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
AssetDatabase.Refresh();
来源:CSDN
作者:作茧自缚的蚕
链接:https://blog.csdn.net/m0_46124411/article/details/103977633