|
1 |
| -global string $UnityExportSets[]; |
2 | 1 | global string $UnityFbxFilePathAttr = "unityFbxModelFilePath";
|
3 | 2 | global string $UnityFbxFileNameAttr = "unityFbxModelFileName";
|
4 | 3 | global string $UnityFbxAnimFilePathAttr = "unityFbxAnimFilePath";
|
@@ -136,7 +135,6 @@ proc string checkNamespaceNeedsUpdate(string $unitySet, string $unityFbxNamespac
|
136 | 135 |
|
137 | 136 | proc importFile(string $filePathStr){
|
138 | 137 | // get the global variables
|
139 |
| - global string $UnityExportSets[]; |
140 | 138 | global string $UnityFbxFilePathAttr;
|
141 | 139 | global string $UnityFbxFileNameAttr;
|
142 | 140 | global string $UnityFbxAnimFilePathAttr;
|
@@ -278,10 +276,6 @@ proc importFile(string $filePathStr){
|
278 | 276 | }
|
279 | 277 | // lock set so it doesn't get deleted when empty
|
280 | 278 | lockNode -lock true $unityExportSet;
|
281 |
| - |
282 |
| - if(!stringArrayContains($unityExportSet, $UnityExportSets)){ |
283 |
| - $UnityExportSets[size($UnityExportSets)] = $unityExportSet; |
284 |
| - } |
285 | 279 | }
|
286 | 280 | }
|
287 | 281 |
|
@@ -418,9 +412,41 @@ proc exportSet(string $unitySet, int $exportAnim){
|
418 | 412 | }
|
419 | 413 | }
|
420 | 414 |
|
| 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 | + |
421 | 449 | proc unityExport(int $exportType){
|
422 |
| - // get the global variables |
423 |
| - global string $UnityExportSets[]; |
424 | 450 |
|
425 | 451 | if(!loadUnityDependencies()){
|
426 | 452 | return;
|
@@ -454,7 +480,8 @@ proc unityExport(int $exportType){
|
454 | 480 |
|
455 | 481 | $i = 0;
|
456 | 482 | string $setsToExport[];
|
457 |
| - for($exportSet in $UnityExportSets){ |
| 483 | + string $unityExportSets[] = getUnityExportSets(); |
| 484 | + for($exportSet in $unityExportSets){ |
458 | 485 | if(!setExists($exportSet)){
|
459 | 486 | continue;
|
460 | 487 | }
|
|
0 commit comments