private static string[] ExportAssets(ContentRef <Resource> inputResource, string exportDir, bool simulate) { // Early-out, if the input Resource isn't available if (!inputResource.IsAvailable) { return(new string[0]); } // If there is no export directory set, derive it from the Resource path in the Data folder if (exportDir == null) { exportDir = AssetInternalHelper.GetSourceMediaBaseDir(inputResource); } bool userAbort = false; bool success = false; // Set up an export operation and process it AssetExportOperation exportOperation = new AssetExportOperation(inputResource.Res, exportDir); exportOperation.ImporterConflictHandler = data => { IAssetImporter userSelection = ResolveImporterConflict(data); if (userSelection == null) { userAbort = true; } return(userSelection); }; success = simulate ? exportOperation.SimulatePerform() : exportOperation.Perform(); // Did we actually do something? if (!simulate && !userAbort) { // If the exporter modified export parameters of the Resource, notify the editor that we have modified it. if (exportOperation.IsAssetInfoChanged) { DualityEditorApp.NotifyObjPropChanged(null, new ObjectSelection(inputResource.Res), ReflectionInfo.Property_Resource_AssetInfo); } // If the operation was a failure, display an error message in the editor UI. if (!success) { MessageBox.Show( string.Format(Properties.GeneralRes.Msg_CantExport_Text, inputResource.Path), Properties.GeneralRes.Msg_CantExport_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } // Global event handling OnExportFinished(exportOperation, success); } return(exportOperation.OutputPaths.ToArray()); }
private static void OnExportFinished(AssetExportOperation operation, bool success) { if (ExportFinished != null) { AssetExportFinishedEventArgs args = new AssetExportFinishedEventArgs( success, operation.Input, operation.OutputPaths); ExportFinished(null, args); } }
private static string[] ExportAssets(ContentRef <Resource> inputResource, string exportDir, bool simulate) { // Early-out, if the input Resource isn't available if (!inputResource.IsAvailable) { return(new string[0]); } // If there is no export directory set, derive it from the Resource path in the Data folder if (exportDir == null) { string resFullNameInData = PathHelper.MakeFilePathRelative(inputResource.FullName, DualityApp.DataDirectory); string resDirInData = Path.GetDirectoryName(resFullNameInData); exportDir = Path.Combine( EditorHelper.SourceMediaDirectory, resDirInData); } bool userAbort = false; bool success = false; // Set up an export operation and process it AssetExportOperation exportOperation = new AssetExportOperation(inputResource.Res, exportDir); exportOperation.ImporterConflictHandler = data => { IAssetImporter userSelection = ResolveImporterConflict(data); if (userSelection == null) { userAbort = true; } return(userSelection); }; success = simulate ? exportOperation.SimulatePerform() : exportOperation.Perform(); // If the operation was a failure, display an error message in the editor UI. if (!simulate && !success && !userAbort) { MessageBox.Show( string.Format(Properties.GeneralRes.Msg_CantExport_Text, inputResource.Path), Properties.GeneralRes.Msg_CantExport_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(exportOperation.OutputPaths.ToArray()); }
private static string[] ExportAssets(ContentRef<Resource> inputResource, string exportDir, bool simulate) { // Early-out, if the input Resource isn't available if (!inputResource.IsAvailable) return new string[0]; // If there is no export directory set, derive it from the Resource path in the Data folder if (exportDir == null) { string resFullNameInData = PathHelper.MakeFilePathRelative(inputResource.FullName, DualityApp.DataDirectory); string resDirInData = Path.GetDirectoryName(resFullNameInData); exportDir = Path.Combine( EditorHelper.SourceMediaDirectory, resDirInData); } bool userAbort = false; bool success = false; // Set up an export operation and process it AssetExportOperation exportOperation = new AssetExportOperation(inputResource.Res, exportDir); exportOperation.ImporterConflictHandler = data => { IAssetImporter userSelection = ResolveImporterConflict(data); if (userSelection == null) userAbort = true; return userSelection; }; success = simulate ? exportOperation.SimulatePerform() : exportOperation.Perform(); // If the operation was a failure, display an error message in the editor UI. if (!simulate && !success && !userAbort) { MessageBox.Show( string.Format(Properties.GeneralRes.Msg_CantExport_Text, inputResource.Path), Properties.GeneralRes.Msg_CantExport_Caption, MessageBoxButtons.OK, MessageBoxIcon.Error); } return exportOperation.OutputPaths.ToArray(); }