private static void SetAssetBundleIdAtSizeAssetBundle(AssetBundleBuildSetting dirSetting, List <string> paths, ProjectAssetsToBundleMapInfo appBundleInfo, string bundleId = null) { var bundleIds = new List <string>(); foreach (var path in paths) { var assetId = Path.GetFileNameWithoutExtension(path); if (assetId == null) { Debug.LogError($"路径{path}获取文件名失败!"); continue; } var assetLowerId = assetId.ToLower(); var finalBundleId = bundleId ?? ($"({IOUtility.GetSomeDirPath(dirSetting.Dir, 3).ToLower()}_{assetLowerId}"); finalBundleId = finalBundleId.ToLower(); if (bundleIds.Contains(finalBundleId)) { bundleIds.Add(finalBundleId); } appBundleInfo.AddMap(assetLowerId, finalBundleId); var assetsPath = UnityIOUtility.GetAssetsPath(path); var importer = AssetImporter.GetAtPath(assetsPath); if (importer == null) { Debug.LogError($"资源{assetsPath}获取导入器失败!"); continue; } dirSetting.UpdateBundleIds(bundleIds); importer.assetBundleName = finalBundleId; importer.assetBundleVariant = ASSETBUNDLE_SHORT_SUFFIX; } }