public void AddABInfo2ResDatas(IResDatas assetBundleConfigFile) { #if UNITY_EDITOR AssetDatabase.RemoveUnusedAssetBundleNames(); var abNames = AssetDatabase.GetAllAssetBundleNames(); if (abNames != null && abNames.Length > 0) { foreach (var abName in abNames) { var depends = AssetDatabase.GetAssetBundleDependencies(abName, false); AssetDataGroup group; var abIndex = assetBundleConfigFile.AddAssetBundleName(abName, depends, out @group); if (abIndex < 0) { continue; } var assets = AssetDatabase.GetAssetPathsFromAssetBundle(abName); foreach (var cell in assets) { var type = AssetDatabase.GetMainAssetTypeAtPath(cell); var code = type.ToCode(); @group.AddAssetData(cell.EndsWith(".unity") ? new AssetData(AssetPath2Name(cell), ResLoadType.ABScene, abIndex, abName, code) : new AssetData(AssetPath2Name(cell), ResLoadType.ABAsset, abIndex, abName, code)); } } } #endif }
public static void AddABInfo2ResDatas(IResDatas resDatas) { AssetDatabase.RemoveUnusedAssetBundleNames(); var abNames = AssetDatabase.GetAllAssetBundleNames(); if (abNames != null && abNames.Length > 0) { foreach (var abName in abNames) { var depends = AssetDatabase.GetAssetBundleDependencies(abName, false); AssetDataGroup group; var abIndex = resDatas.AddAssetBundleName(abName, depends, out @group); if (abIndex < 0) { continue; } var assets = AssetDatabase.GetAssetPathsFromAssetBundle(abName); foreach (var cell in assets) { @group.AddAssetData(cell.EndsWith(".unity") ? new AssetData(AssetPath2Name(cell), ResType.ABScene, abIndex, abName) : new AssetData(AssetPath2Name(cell), ResType.ABAsset, abIndex, abName)); } } } }