Version: 2020.2

AssetDatabase.RemoveAssetBundleName

切换到手册
public static bool RemoveAssetBundleName (string assetBundleName, bool forceRemove);

参数

assetBundleName 要删除的 assetBundle 名称。
forceRemove 用于指示您是否要将 assetBundle 名称删除(即使您正在使用它)的标志。

描述

从资源数据库中删除 assetBundle 名称。ForceRemove 标志用于指示您是否要将其删除,即使您正在使用它。

using UnityEditor;
using UnityEngine;

public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Remove Bundle Name")] static void RemoveAssetBundleNameExample() { //Remove Asset Bundle name that is on Cube.prefab and it's dependencies var prefabPath = "Assets/Prefabs/Cube.prefab"; var assetBundleName = AssetDatabase.GetImplicitAssetBundleName(prefabPath); var assetBundleDependencies = AssetDatabase.GetAssetBundleDependencies(assetBundleName, true); AssetDatabase.RemoveAssetBundleName(assetBundleName, true); foreach (var bundleName in assetBundleDependencies) { AssetDatabase.RemoveAssetBundleName(bundleName, true); } } }