@@ -70,6 +70,20 @@ proc int loadUnityPlugin(string $plugin){
70
70
return true;
71
71
};
72
72
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
+
73
87
proc importFile(string $filePathStr){
74
88
// get the global variables
75
89
global string $UnityExportSets[];
@@ -96,6 +110,22 @@ proc importFile(string $filePathStr){
96
110
}
97
111
$unityExportSet = `format -stringArg $nameWithoutExt $UnityExportSetNameFormat`;
98
112
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
+
99
129
// Gather everything that is in the scene
100
130
$origItemsInScene = `ls -tr -o -r true`;
101
131
@@ -116,9 +146,6 @@ proc importFile(string $filePathStr){
116
146
storeAttribute($unityExportSet, $UnityFbxFileNameAttr, "");
117
147
}
118
148
119
- string $origNamespace = `namespaceInfo -cur`;
120
-
121
- namespace -add $nameWithoutExt;
122
149
namespace -set $nameWithoutExt;
123
150
file -import -type "fbx" -namespace $nameWithoutExt $filePathStr;
124
151
0 commit comments