@@ -622,6 +622,9 @@ proc setupNewExportSet(string $exportPath, int $exportAnimOnly, string $selected
622
622
setExportSetAttributes($unityExportSet, $isAnimFile, $setCreated, $exportAttrs, $targetNamespace);
623
623
624
624
if (setExists($unityExportSet) == true){
625
+ // clear contents of set
626
+ sets -clear $unityExportSet;
627
+
625
628
// add newly imported items to set
626
629
if (size($selectedObjects) > 0){
627
630
sets -include $unityExportSet $selectedObjects;
@@ -695,14 +698,35 @@ proc unityExport(int $exportType){
695
698
if(size($setsToExport) <= 0){
696
699
$unityProject = `optionVar -q "UnityProject"`;
697
700
$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){
700
703
return;
701
704
}
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 + "\"";
703
727
eval $exportCmd;
704
728
705
- setupNewExportSet($exportPath[0] , $exportAnimOnly, $origSelection);
729
+ setupNewExportSet($exportFilePath , $exportAnimOnly, $origSelection);
706
730
return;
707
731
}
708
732
0 commit comments