@@ -702,7 +702,7 @@ global proc unityOnCreateExportSet(
702
702
print ("Nothing selected");
703
703
return;
704
704
}
705
-
705
+
706
706
string $namespace = `textField -q -text $namespaceField`;
707
707
if ($namespace == ""){
708
708
$namespace = ":";
@@ -811,20 +811,36 @@ proc createExportSetDialog(int $exportType){
811
811
812
812
string $mainOptions = `columnLayout -adjustableColumn true -p $container`;
813
813
814
- // go through selection to find common namespace to set as default
815
- string $commonNamespace = ":";
816
- int $maxNamespaceCount = 0;
814
+ // gather up all the unique namespaces
815
+ string $selectedNamespaces[];
817
816
for($i = 0; $i < size($origSelection); $i++){
818
817
string $currNamespace = getObjectNamespace($origSelection[$i]);
819
- while ($currNamespace != ":"){
820
- // get contents of namespace
821
- string $namespaceContents[] = `namespaceInfo -ls $currNamespace`;
822
- string $intersection[] = getIntersection($origSelection, $namespaceContents);
823
- if(size($intersection) > $maxNamespaceCount){
824
- $commonNamespace = $currNamespace;
825
- $maxNamespaceCount = size($intersection);
826
- }
818
+ while ($currNamespace != ":" && !stringArrayContains($currNamespace, $selectedNamespaces)){
819
+ $selectedNamespaces[size($selectedNamespaces)] = $currNamespace;
827
820
$currNamespace = `namespaceInfo -p $currNamespace`;
821
+ // make sure the namespace always starts with a colon
822
+ if(!startsWith($currNamespace, ":")){
823
+ $currNamespace = ":" + $currNamespace;
824
+ }
825
+ }
826
+ }
827
+
828
+ // go through selection to find common namespace to set as default
829
+ string $commonNamespace = ":";
830
+ int $maxNamespaceCount = 0;
831
+ for($i = 0; $i < size($selectedNamespaces); $i++){
832
+ $currNamespace = $selectedNamespaces[$i];
833
+ // get contents of namespace
834
+ string $namespaceContents[] = `namespaceInfo -ls $currNamespace -r`;
835
+ string $intersection[] = getIntersection($origSelection, $namespaceContents);
836
+ int $intersectionSize = size($intersection);
837
+ if($intersectionSize > $maxNamespaceCount ||
838
+ // prefer more specific namespaces
839
+ ($maxNamespaceCount > 0 &&
840
+ $intersectionSize == $maxNamespaceCount &&
841
+ size($currNamespace) > size($commonNamespace))){
842
+ $commonNamespace = $currNamespace;
843
+ $maxNamespaceCount = $intersectionSize;
828
844
}
829
845
}
830
846
0 commit comments