private void Export(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming, IEnumerable <Model.ConnectionData> connectionsToOutput, Action <Model.NodeData, string, float> progressFunc) { if (incoming == null) { return; } var exportPath = GetExportPath(m_exportPath[target]); if (m_exportOption[target] == (int)ExportOption.DeleteAndRecreateExportDirectory) { if (Directory.Exists(exportPath)) { FileUtility.DeleteDirectory(exportPath, true); } } if (m_exportOption[target] != (int)ExportOption.ErrorIfNoExportDirectoryFound) { if (!Directory.Exists(exportPath)) { Directory.CreateDirectory(exportPath); } } var report = new ExportReport(node); var cacheFolderDepth = Model.Settings.Path.BundleBuilderCachePath.Split(Model.Settings.UNITY_FOLDER_SEPARATOR).Length; foreach (var ag in incoming) { foreach (var groupKey in ag.assetGroups.Keys) { var inputSources = ag.assetGroups[groupKey]; foreach (var source in inputSources) { var destinationSourcePath = source.importFrom; string destination = null; if (m_flattenDir[target] == 0) { // in bundleBulider, use platform-package folder for export destination. if (destinationSourcePath.StartsWith(Model.Settings.Path.BundleBuilderCachePath)) { var splitted = destinationSourcePath.Split(Model.Settings.UNITY_FOLDER_SEPARATOR); var reducedArray = new string[splitted.Length - cacheFolderDepth]; Array.Copy(splitted, cacheFolderDepth, reducedArray, 0, reducedArray.Length); var fromDepthToEnd = string.Join(Model.Settings.UNITY_FOLDER_SEPARATOR.ToString(), reducedArray); destinationSourcePath = fromDepthToEnd; } destination = FileUtility.PathCombine(exportPath, destinationSourcePath); } else { destination = FileUtility.PathCombine(exportPath, source.fileNameAndExtension); } var parentDir = Directory.GetParent(destination).ToString(); if (!Directory.Exists(parentDir)) { Directory.CreateDirectory(parentDir); } if (File.Exists(destination)) { File.Delete(destination); } if (string.IsNullOrEmpty(source.importFrom)) { report.AddErrorEntry(source.absolutePath, destination, "Source Asset import path is empty; given asset is not imported by Unity."); continue; } try { if (progressFunc != null) { progressFunc(node, string.Format("Copying {0}", source.fileNameAndExtension), 0.5f); } File.Copy(source.importFrom, destination); report.AddExportedEntry(source.importFrom, destination); } catch (Exception e) { report.AddErrorEntry(source.importFrom, destination, e.Message); } source.exportTo = destination; } } } AssetBundleBuildReport.AddExportReport(report); }
static public void AddExportReport(ExportReport r) { Manager.ExportReports.Add(r); }