assetBundleName | 需要了解所依赖项的 AssetBundle 的名称。 |
recursive | false 时,仅返回输入的直接依赖项 AssetBundle;true 时,包括输入的所有间接依赖项。 |
string[] 输入所依赖的所有 AssetBundle 的名称。
指定 assetBundleName 时,返回它所依赖的 AssetBundle 列表。
using System.Text; using UnityEditor; using UnityEngine;
public class AssetDatabaseExamples : MonoBehaviour { [MenuItem("AssetDatabase/Find Bundles With Dependencies")] static void BundleDependency() { var allBundleNames = AssetDatabase.GetAllAssetBundleNames(); foreach (var bundle in allBundleNames) { var dependencies = AssetDatabase.GetAssetBundleDependencies(bundle, true); if (dependencies.Length == 0) continue; var dependencyString = new StringBuilder(); foreach (var dependency in dependencies) { dependencyString.Append($"\"{dependency}\" "); } Debug.Log($"{bundle} depends on {dependencyString}"); } } }