Skip to content

Commit 05ee210

Browse files
committed
don't store export set, get unity sets on export
1 parent b7895c3 commit 05ee210

File tree

1 file changed

+36
-9
lines changed

1 file changed

+36
-9
lines changed

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

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
global string $UnityExportSets[];
21
global string $UnityFbxFilePathAttr = "unityFbxModelFilePath";
32
global string $UnityFbxFileNameAttr = "unityFbxModelFileName";
43
global string $UnityFbxAnimFilePathAttr = "unityFbxAnimFilePath";
@@ -136,7 +135,6 @@ proc string checkNamespaceNeedsUpdate(string $unitySet, string $unityFbxNamespac
136135

137136
proc importFile(string $filePathStr){
138137
// get the global variables
139-
global string $UnityExportSets[];
140138
global string $UnityFbxFilePathAttr;
141139
global string $UnityFbxFileNameAttr;
142140
global string $UnityFbxAnimFilePathAttr;
@@ -278,10 +276,6 @@ proc importFile(string $filePathStr){
278276
}
279277
// lock set so it doesn't get deleted when empty
280278
lockNode -lock true $unityExportSet;
281-
282-
if(!stringArrayContains($unityExportSet, $UnityExportSets)){
283-
$UnityExportSets[size($UnityExportSets)] = $unityExportSet;
284-
}
285279
}
286280
}
287281

@@ -418,9 +412,41 @@ proc exportSet(string $unitySet, int $exportAnim){
418412
}
419413
}
420414

415+
proc int isUnityExportSet(string $mayaSet){
416+
global string $UnityFbxFilePathAttr;
417+
global string $UnityFbxFileNameAttr;
418+
419+
if(!endsWith($mayaSet, "_UnityExportSet")){
420+
return false;
421+
}
422+
423+
if(!`attributeExists $UnityFbxFilePathAttr $mayaSet`){
424+
return false;
425+
}
426+
427+
if(!`attributeExists $UnityFbxFileNameAttr $mayaSet`){
428+
return false;
429+
}
430+
return true;
431+
}
432+
433+
proc string[] getUnityExportSets(){
434+
//if the selection set ends w "_UnityExportSet" and it has at least the custom attributes UnityFbxModelFilePath & UnityFbxModelFileName then it's one of ours.
435+
string $unityExportSets[];
436+
437+
string $mayaSets[] = `listSets -allSets`;
438+
439+
int $i = 0;
440+
for($k=0; $k<size($mayaSets); ++$k){
441+
if(isUnityExportSet($mayaSets[$k])){
442+
$unityExportSets[$i] = $mayaSets[$k];
443+
$i++;
444+
}
445+
}
446+
return $unityExportSets;
447+
}
448+
421449
proc unityExport(int $exportType){
422-
// get the global variables
423-
global string $UnityExportSets[];
424450

425451
if(!loadUnityDependencies()){
426452
return;
@@ -454,7 +480,8 @@ proc unityExport(int $exportType){
454480

455481
$i = 0;
456482
string $setsToExport[];
457-
for($exportSet in $UnityExportSets){
483+
string $unityExportSets[] = getUnityExportSets();
484+
for($exportSet in $unityExportSets){
458485
if(!setExists($exportSet)){
459486
continue;
460487
}

0 commit comments

Comments
 (0)