@@ -573,6 +573,66 @@ proc string[] getUnityExportSets(){
573
573
return $unityExportSets;
574
574
}
575
575
576
+ proc setupNewExportSet(
577
+ string $namespace,
578
+ string $modelPath,
579
+ string $modelFilename,
580
+ string $animPath,
581
+ string $animFilename){
582
+
583
+ $fileNameWithoutExt = $exportAttrs[$UnityFileNameWithoutExtIndex];
584
+
585
+ $unityExportSet = getNewExportSetName($fileNameWithoutExt);
586
+
587
+ string $origNamespace = `namespaceInfo -cur -an`;
588
+ string $targetNamespace = getTargetNamespaceName($fileNameWithoutExt);
589
+
590
+ $setNamespace = getSetNamespace($unityExportSet);
591
+ $setNamespaceExists = ($setNamespace != "");
592
+ if($setNamespaceExists){
593
+ $targetNamespace = $setNamespace;
594
+ }
595
+ else{
596
+ // warn if namespace already exists
597
+ if(`namespace -exists $targetNamespace`){
598
+ if(!showConfirmDialog("Warning: " + $exportFileName,
599
+ $targetNamespace + " namespace already exists, the selected objects will be added to the existing namespace and export set.",
600
+ "Continue", "Cancel"
601
+ )){
602
+ // cancelled, don't import this fbx
603
+ return;
604
+ }
605
+ }
606
+ else{
607
+ namespace -add $targetNamespace;
608
+ }
609
+ }
610
+
611
+ // Get or create the Unity Fbx Export Set
612
+ $setCreated = getOrCreateExportSet($unityExportSet, $origNamespace);
613
+
614
+ setExportSetAttributes($unityExportSet, $isAnimFile, $setCreated, $exportAttrs, $targetNamespace);
615
+
616
+ if (setExists($unityExportSet) == true){
617
+ // clear contents of set
618
+ sets -clear $unityExportSet;
619
+
620
+ // add newly imported items to set
621
+ if (size($selectedObjects) > 0){
622
+ sets -include $unityExportSet $selectedObjects;
623
+ }
624
+ }
625
+
626
+ // add to the targetNamespace
627
+ // iterate over all selected objects and rename
628
+ for($object in $selectedObjects){
629
+ rename $object ($targetNamespace + ":" + $object);
630
+ }
631
+
632
+ // switch project if file exported to a different Unity project
633
+ switchUnityProject($exportPath);
634
+ }
635
+
576
636
proc setupNewExportSet(string $exportPath, int $exportAnimOnly, string $selectedObjects[]){
577
637
global int $UnityFbxFilePathIndex;
578
638
global int $UnityFbxFileNameIndex;
@@ -756,10 +816,22 @@ global proc unityExportModelAnim(){
756
816
unityExport($UnityExportModelAnim);
757
817
}
758
818
759
- global proc onCreateExportSet(string $window, string $contents){
760
- print ("\n" + $contents + "\n");
761
- string $text = `textField -q -text $contents`;
762
- print ("contents: " + $text);
819
+ global proc unityOnCreateExportSet(
820
+ string $window,
821
+ string $namespaceField,
822
+ string $modelPathField,
823
+ string $modelFileField,
824
+ string $animPathField,
825
+ string $animFileField,
826
+ string $origSelection[]){
827
+
828
+ string $namespace = `textField -q -text $namespaceField`;
829
+ string $modelPath = `textField -q -text $modelPathField`;
830
+ string $modelFilename = `textField -q -text $modelFileField`;
831
+ string $animPath = `textField -q -text $animPathField`;
832
+ string $animFilename = `textField -q -text $animFileField`;
833
+
834
+ //setupNewExportSet("", 0, $origSelection);
763
835
764
836
deleteUI -window $window;
765
837
}
@@ -830,17 +902,29 @@ global proc unityCreateExportSet(){
830
902
831
903
string $animFilePath = createFilePathField("Unity FBX Anim File Path", $mainOptions);
832
904
string $animFileName = createTextFieldWithLabel("Unity FBX Anim File Name", $mainOptions);
833
-
905
+
906
+ int $buttonWidth = 158;
834
907
string $buttons = `rowLayout
835
908
-numberOfColumns 3
836
909
-adjustableColumn3 1
837
- // -columnWidth3 120 120 120
910
+ -columnWidth3 $buttonWidth $buttonWidth $buttonWidth
838
911
-columnAlign3 "center" "center" "center" -p $container`;
839
912
840
- button -label "Create Set and Export" -command "sphere" -p $buttons;
841
- button -label "Create Set" -command ("onCreateExportSet " + $window + " " + $namespaceField) -p $buttons;
842
- button -label "Cancel" -command ("deleteUI -window " + $window) -p $buttons;
843
-
913
+ string $modelFilePath = " " + $modelFilePath + " " + $modelFileName;
914
+ string $animFilePath = " " + $animFilePath + " " + $animFileName;
915
+
916
+ button -label "Create Set and Export"
917
+ -width $buttonWidth
918
+ -command "sphere"
919
+ -p $buttons;
920
+ button -label "Create Set"
921
+ -width $buttonWidth
922
+ -command ("unityOnCreateExportSet " + $window + " " + $namespaceField + $modelFilePath + $animFilePath + " " + $origSelection)
923
+ -p $buttons;
924
+ button -label "Cancel"
925
+ -width $buttonWidth
926
+ -command ("deleteUI -window " + $window)
927
+ -p $buttons;
844
928
845
929
formLayout -edit
846
930
-attachForm $buttons "bottom" 1
@@ -852,6 +936,4 @@ global proc unityCreateExportSet(){
852
936
853
937
setParent ..;
854
938
showWindow $window;
855
-
856
- //setupNewExportSet("", 0, $origSelection);
857
939
}
0 commit comments