Skip to content

Commit 98f5e39

Browse files
committed
show warning if namespace already exists
1 parent 0c7907a commit 98f5e39

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

Assets/Integrations/Autodesk/maya/scripts/unityCommands.mel

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,20 @@ proc int loadUnityPlugin(string $plugin){
7070
return true;
7171
};
7272

73+
// show a yes/no style dialog, return true if user clicked confirm, false if user canceled
74+
proc int showConfirmDialog(string $title, string $message, string $confirmButtonName, string $cancelButtonName){
75+
// create a confirm dialog with a yes and no button. Specif
76+
$response = `confirmDialog -title $title
77+
-message $message
78+
-button $confirmButtonName
79+
-button $cancelButtonName
80+
-defaultButton $confirmButtonName
81+
-cancelButton $cancelButtonName
82+
-dismissString $cancelButtonName`;
83+
84+
return ( $response == $confirmButtonName );
85+
}
86+
7387
proc importFile(string $filePathStr){
7488
// get the global variables
7589
global string $UnityExportSets[];
@@ -96,6 +110,22 @@ proc importFile(string $filePathStr){
96110
}
97111
$unityExportSet = `format -stringArg $nameWithoutExt $UnityExportSetNameFormat`;
98112

113+
string $origNamespace = `namespaceInfo -cur`;
114+
115+
// warn if namespace already exists
116+
if(`namespace -exists $nameWithoutExt`){
117+
if(!showConfirmDialog("Warning",
118+
"Namespace already exists, the imported objects will be added to the existing namespace and export set.",
119+
"Continue", "Cancel"
120+
)){
121+
// cancelled, don't import this fbx
122+
return;
123+
}
124+
}
125+
else{
126+
namespace -add $nameWithoutExt;
127+
}
128+
99129
// Gather everything that is in the scene
100130
$origItemsInScene = `ls -tr -o -r true`;
101131

@@ -116,9 +146,6 @@ proc importFile(string $filePathStr){
116146
storeAttribute($unityExportSet, $UnityFbxFileNameAttr, "");
117147
}
118148

119-
string $origNamespace = `namespaceInfo -cur`;
120-
121-
namespace -add $nameWithoutExt;
122149
namespace -set $nameWithoutExt;
123150
file -import -type "fbx" -namespace $nameWithoutExt $filePathStr;
124151

0 commit comments

Comments
 (0)