Skip to content

Commit 5cf3dfc

Browse files
committed
warn user if export set contents will be overwritten
- this happens when exporting to a filename that already has a corresponding export set in the scene.
1 parent 57231c9 commit 5cf3dfc

File tree

1 file changed

+28
-4
lines changed
  • Assets/com.unity.formats.fbx/Editor/Integrations/Autodesk/maya/scripts

1 file changed

+28
-4
lines changed

Assets/com.unity.formats.fbx/Editor/Integrations/Autodesk/maya/scripts/unityCommands.mel

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,9 @@ proc setupNewExportSet(string $exportPath, int $exportAnimOnly, string $selected
622622
setExportSetAttributes($unityExportSet, $isAnimFile, $setCreated, $exportAttrs, $targetNamespace);
623623

624624
if (setExists($unityExportSet) == true){
625+
// clear contents of set
626+
sets -clear $unityExportSet;
627+
625628
// add newly imported items to set
626629
if (size($selectedObjects) > 0){
627630
sets -include $unityExportSet $selectedObjects;
@@ -695,14 +698,35 @@ proc unityExport(int $exportType){
695698
if(size($setsToExport) <= 0){
696699
$unityProject = `optionVar -q "UnityProject"`;
697700
$unityProject = $unityProject + "/Assets";
698-
$exportPath = `fileDialog2 -ds 2 -cap "FBX Export Selection" -dir $unityProject -ff "*.fbx" -fm 0`;
699-
if(size($exportPath)<=0){
701+
$exportPaths = `fileDialog2 -ds 2 -cap "FBX Export Selection" -dir $unityProject -ff "*.fbx" -fm 0`;
702+
if(size($exportPaths)<=0){
700703
return;
701704
}
702-
$exportCmd = "file -force -options \"\" -typ \"FBX export\" -pr -es \"" + $exportPath[0] + "\"";
705+
$exportFilePath = $exportPaths[0];
706+
707+
// check if export set with this filename already exists in the scene, and warn user that
708+
// if it does the existing set will be overriden
709+
global int $UnityFileNameWithoutExtIndex;
710+
711+
// Get the export set attributes
712+
$exportAttrs = getExportSetAttributes($exportFilePath, $exportAnimOnly);
713+
$exportSetName = getNewExportSetName($exportAttrs[$UnityFileNameWithoutExtIndex]);
714+
if(setExists($exportSetName)){
715+
// warn user
716+
if(!showConfirmDialog("Warning",
717+
"Exporting to " + $exportFilePath + " will overwrite contents of " + $exportSetName + " export set. To export selection + contents of set, first add selection to set.",
718+
"Continue", "Cancel"
719+
)){
720+
// cancelled, don't export this fbx
721+
print ("Export to " + $exportFilePath + " cancelled");
722+
return;
723+
}
724+
}
725+
726+
$exportCmd = "file -force -options \"\" -typ \"FBX export\" -pr -es \"" + $exportFilePath + "\"";
703727
eval $exportCmd;
704728

705-
setupNewExportSet($exportPath[0], $exportAnimOnly, $origSelection);
729+
setupNewExportSet($exportFilePath, $exportAnimOnly, $origSelection);
706730
return;
707731
}
708732

0 commit comments

Comments
 (0)