//无规则设置bundle名称 路径 修改路径的方法 bundle的名字 static void InternalSetBundleName(string path, Func <string, string> modifyPath, AssetImporter importer = null, string bundleName = null) { if (importer == null) { importer = AssetImporter.GetAtPath(path); } if (string.IsNullOrEmpty(bundleName)) { bundleName = modifyPath(path); } //如果bundleName有后缀,需要删除 string extension = Path.GetExtension(bundleName); if (!string.IsNullOrEmpty(extension)) { bundleName = bundleName.Replace(extension, ""); } string file_name = bundleName; BuildRule rule = BundleBuildRule.MatchRule(path); if (rule != null) { bundleName = rule.GetBundleName(bundleName); } if (bundleName.Contains("Material")) { //针对UI int index = bundleName.IndexOf("Material"); bundleName = bundleName.Substring(0, index - 1); } else if (bundleName.Contains("Materials")) { //针对模型导入 int index = bundleName.IndexOf("Materials"); bundleName = bundleName.Substring(0, index - 1); } if (bundleName.Contains(" ")) { Debug.LogError("当前bundleName存在空格 : " + bundleName); return; } importer.assetBundleName = bundleName + ABPathHelper.Unity3dSuffix; }
//通过规则设置Bundle的名称 static void InternalSetBundleNameByRule(string path, Func <string, string> modifyPath, AssetImporter importer = null, string bundleName = null) { if (importer == null) { importer = AssetImporter.GetAtPath(path); } if (string.IsNullOrEmpty(bundleName)) { bundleName = modifyPath(path); } string extension = Path.GetExtension(bundleName); if (string.IsNullOrEmpty(extension) == false) { bundleName = bundleName.Replace(extension, ""); } string file_name = bundleName; BuildRule rule = BundleBuildRule.MatchRule(path); if (rule != null) { bundleName = rule.GetBundleName(bundleName); } if (bundleName.Contains("Material")) { int index = bundleName.IndexOf("Material"); bundleName = bundleName.Substring(0, index - 1); } else if (bundleName.Contains("Materials")) { //针对模型导入 int index = bundleName.IndexOf("Materials"); bundleName = bundleName.Substring(0, index - 1); } if (string.IsNullOrEmpty(bundleName)) { importer.assetBundleName = string.Empty; } else { importer.assetBundleName = bundleName + ABPathHelper.Unity3dSuffix; } }