Skip to content

Commit ded816d

Browse files
committed
check if set namespace attr needs to change on import as well
1 parent dc30925 commit ded816d

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,22 @@ proc string getNewNamespace(string $n1, string $n2){
111111
return $newNamespace;
112112
}
113113

114+
proc checkNamespaceNeedsUpdate(string $unitySet, string $objectNamespace){
115+
global string $UnityFbxNamespaceAttr;
116+
117+
string $unity_fbx_namespace = getAttribute($unitySet, $UnityFbxNamespaceAttr);
118+
string $newNamespace = getNewNamespace($unity_fbx_namespace, $objectNamespace);
119+
if($unity_fbx_namespace != $newNamespace){
120+
// popup asking to change namespace value to new namespace
121+
if(showConfirmDialog($unitySet,
122+
"Set namespace has been modified from "+$unity_fbx_namespace+" to "+$newNamespace+", update export set namespace attribute?",
123+
"Yes", "No"
124+
)){
125+
storeAttribute($unitySet, $UnityFbxNamespaceAttr, $newNamespace);
126+
}
127+
}
128+
}
129+
114130
proc importFile(string $filePathStr){
115131
// get the global variables
116132
global string $UnityExportSets[];
@@ -143,6 +159,11 @@ proc importFile(string $filePathStr){
143159

144160
$setNamespaceExists = false;
145161
if (setExists($unityExportSet)){
162+
string $unitySetContents[] = `listConnections $unityExportSet`;
163+
if(size($unitySetContents) > 0){
164+
checkNamespaceNeedsUpdate($unityExportSet, getObjectNamespace($unitySetContents[0]));
165+
}
166+
146167
// get namespace from set
147168
$setNamespace = getAttribute($unityExportSet, $UnityFbxNamespaceAttr);
148169
if($setNamespace != "" && `namespace -exists $setNamespace`){
@@ -331,16 +352,7 @@ proc exportSet(string $unitySet, int $exportAnim){
331352
string $unity_fbx_namespace = getAttribute($unitySet, $UnityFbxNamespaceAttr);
332353

333354
if(size($unitySetContents) > 0){
334-
string $newNamespace = getNewNamespace($unity_fbx_namespace, getObjectNamespace($unitySetContents[0]));
335-
if($unity_fbx_namespace != $newNamespace){
336-
// popup asking to change namespace value to new namespace
337-
if(showConfirmDialog($unitySet,
338-
"Set namespace has been modified from "+$unity_fbx_namespace+" to "+$newNamespace+", update export set namespace attribute?",
339-
"Yes", "No"
340-
)){
341-
storeAttribute($unitySet, $UnityFbxNamespaceAttr, $newNamespace);
342-
}
343-
}
355+
checkNamespaceNeedsUpdate($unitySet, getObjectNamespace($unitySetContents[0]));
344356
}
345357

346358
string $animatedObjectSet = "";

0 commit comments

Comments
 (0)