public static string AddBundle(this SerializedProperty bundles, string assetPath, BundleType bundleType = BundleType.Static) { string abName = AssetDatabase.GetImplicitAssetBundleName(assetPath); if (string.IsNullOrEmpty(abName)) { abName = Path.GetFileNameWithoutExtension(assetPath).ToLower(); if (bundles.FindIndex(abName) >= 0) { abName += $"_conflict_{DateTime.Now.ToBinary()}"; } var importer = AssetImporter.GetAtPath(assetPath); importer.assetBundleName = abName; } else { if (bundles.FindIndex(abName) >= 0) { return(string.Empty); } } return(bundles.AddBundleByAbName(abName, bundleType)); }
public void Import(params string[] assetBundleNames) { foreach (string assetBundleName in assetBundleNames) { _bundlesSp.AddBundleByAbName(assetBundleName); } Reload(); }
public static string AddBundle(this SerializedProperty bundles, string abName, BundleType bundleType, params string[] assetPaths) { foreach (string path in assetPaths) { if (!File.Exists(path)) { continue; } var importer = AssetImporter.GetAtPath(path); string oldName = importer.assetBundleName; importer.assetBundleName = abName; if (!string.IsNullOrEmpty(oldName)) { AssetDatabase.RemoveAssetBundleName(oldName, false); } } return(bundles.AddBundleByAbName(abName, bundleType)); }