@@ -573,45 +573,63 @@ proc string[] getUnityExportSets(){
573
573
return $unityExportSets;
574
574
}
575
575
576
- proc setupNewExportSet (
576
+ proc setupNewExportSet2 (
577
577
string $namespace,
578
578
string $modelPath,
579
579
string $modelFilename,
580
580
string $animPath,
581
- string $animFilename){
581
+ string $animFilename,
582
+ string $selectedObjects[]){
582
583
583
- $fileNameWithoutExt = $exportAttrs[$UnityFileNameWithoutExtIndex];
584
+ if ($modelFilename == "" && $animFilename == ""){
585
+ return;
586
+ }
584
587
585
- $unityExportSet = getNewExportSetName($fileNameWithoutExt);
588
+ if ($modelPath == "" && $animPath == ""){
589
+ return;
590
+ }
591
+
592
+ string $exportFileNameWithoutExt = formValidObjectName(basename($modelFilename, ".fbx"));
593
+
594
+ $unityExportSet = getNewExportSetName($exportFileNameWithoutExt);
586
595
587
596
string $origNamespace = `namespaceInfo -cur -an`;
588
- string $targetNamespace = getTargetNamespaceName($fileNameWithoutExt);
589
597
590
- $setNamespace = getSetNamespace($unityExportSet);
591
- $setNamespaceExists = ($setNamespace != "");
592
- if($setNamespaceExists){
593
- $targetNamespace = $setNamespace;
598
+ if($namespace == ":"){
599
+ // do nothing
594
600
}
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;
601
+ // warn if namespace already exists
602
+ else if(`namespace -exists $namespace`){
603
+ if(!showConfirmDialog("Warning: " + $modelFilename,
604
+ $namespace + " namespace already exists, the selected objects will be added to the existing namespace and export set.",
605
+ "Continue", "Cancel"
606
+ )){
607
+ // cancelled, don't import this fbx
608
+ return;
608
609
}
609
610
}
611
+ else{
612
+ namespace -add $namespace;
613
+ }
610
614
611
615
// Get or create the Unity Fbx Export Set
612
616
$setCreated = getOrCreateExportSet($unityExportSet, $origNamespace);
613
617
614
- setExportSetAttributes($unityExportSet, $isAnimFile, $setCreated, $exportAttrs, $targetNamespace);
618
+ global int $UnityFbxFilePathIndex;
619
+ global int $UnityFbxFileNameIndex;
620
+ global int $UnityFbxAnimFilePathIndex;
621
+ global int $UnityFbxAnimFileNameIndex;
622
+ global int $UnityFileNameWithoutExtIndex;
623
+
624
+ // Get the export set attributes
625
+ string $exportAttrs[5];
626
+ $exportAttrs[$UnityFbxFilePathIndex] = $modelPath;
627
+ $exportAttrs[$UnityFbxFileNameIndex] = $modelFilename;
628
+ $exportAttrs[$UnityFbxAnimFilePathIndex] = $animPath;
629
+ $exportAttrs[$UnityFbxAnimFileNameIndex] = $animFilename;
630
+ $exportAttrs[$UnityFileNameWithoutExtIndex] = $exportFileNameWithoutExt;
631
+
632
+ setExportSetAttributes($unityExportSet, /*$isAnimFile*/ false, $setCreated, $exportAttrs, $namespace);
615
633
616
634
if (setExists($unityExportSet) == true){
617
635
// clear contents of set
@@ -625,12 +643,14 @@ proc setupNewExportSet(
625
643
626
644
// add to the targetNamespace
627
645
// iterate over all selected objects and rename
628
- for($object in $selectedObjects){
629
- rename $object ($targetNamespace + ":" + $object);
646
+ if ($namespace != ""){
647
+ for($object in $selectedObjects){
648
+ rename $object ($namespace + ":" + $object);
649
+ }
630
650
}
631
651
632
652
// switch project if file exported to a different Unity project
633
- switchUnityProject($exportPath );
653
+ switchUnityProject($modelPath );
634
654
}
635
655
636
656
proc setupNewExportSet(string $exportPath, int $exportAnimOnly, string $selectedObjects[]){
@@ -822,16 +842,37 @@ global proc unityOnCreateExportSet(
822
842
string $modelPathField,
823
843
string $modelFileField,
824
844
string $animPathField,
825
- string $animFileField,
826
- string $origSelection[]){
845
+ string $animFileField){
846
+
847
+ $origSelection = `ls -sl`;
848
+ if(size($origSelection) <= 0){
849
+ // nothing selected
850
+ print ("Nothing selected");
851
+ return;
852
+ }
827
853
828
854
string $namespace = `textField -q -text $namespaceField`;
855
+ if ($namespace == ""){
856
+ $namespace = ":";
857
+ }
829
858
string $modelPath = `textField -q -text $modelPathField`;
830
859
string $modelFilename = `textField -q -text $modelFileField`;
860
+ if ($modelFilename != "" && !endsWith($modelFilename, ".fbx")){
861
+ $modelFilename = $modelFilename + ".fbx";
862
+ }
831
863
string $animPath = `textField -q -text $animPathField`;
832
864
string $animFilename = `textField -q -text $animFileField`;
865
+ if ($animFilename != "" && !endsWith($animFilename, ".fbx")){
866
+ $animFilename = $animFilename + ".fbx";
867
+ }
833
868
834
- //setupNewExportSet("", 0, $origSelection);
869
+ setupNewExportSet2(
870
+ $namespace,
871
+ $modelPath,
872
+ $modelFilename,
873
+ $animPath,
874
+ $animFilename,
875
+ $origSelection);
835
876
836
877
deleteUI -window $window;
837
878
}
@@ -897,11 +938,11 @@ global proc unityCreateExportSet(){
897
938
// get namespace
898
939
string $namespaceField = createTextFieldWithLabel("Unity FBX namespace", $mainOptions);
899
940
900
- string $modelFilePath = createFilePathField("Unity FBX Model File Path", $mainOptions);
901
- string $modelFileName = createTextFieldWithLabel("Unity FBX Model File Name", $mainOptions);
941
+ string $modelFilePathField = createFilePathField("Unity FBX Model File Path", $mainOptions);
942
+ string $modelFileNameField = createTextFieldWithLabel("Unity FBX Model File Name", $mainOptions);
902
943
903
- string $animFilePath = createFilePathField("Unity FBX Anim File Path", $mainOptions);
904
- string $animFileName = createTextFieldWithLabel("Unity FBX Anim File Name", $mainOptions);
944
+ string $animFilePathField = createFilePathField("Unity FBX Anim File Path", $mainOptions);
945
+ string $animFileNameField = createTextFieldWithLabel("Unity FBX Anim File Name", $mainOptions);
905
946
906
947
int $buttonWidth = 158;
907
948
string $buttons = `rowLayout
@@ -910,16 +951,17 @@ global proc unityCreateExportSet(){
910
951
-columnWidth3 $buttonWidth $buttonWidth $buttonWidth
911
952
-columnAlign3 "center" "center" "center" -p $container`;
912
953
913
- string $modelFilePath = " " + $modelFilePath + " " + $modelFileName;
914
- string $animFilePath = " " + $animFilePath + " " + $animFileName;
954
+ string $modelFilePath = " " + $modelFilePathField + " " + $modelFileNameField;
955
+ string $animFilePath = " " + $animFilePathField + " " + $animFileNameField;
956
+ string $createExportSetCommand = "unityOnCreateExportSet " + $window + " " + $namespaceField + $modelFilePath + $animFilePath;
915
957
916
958
button -label "Create Set and Export"
917
959
-width $buttonWidth
918
- -command "sphere"
960
+ -command ($createExportSetCommand + ";" + "unityExportModelAnim()")
919
961
-p $buttons;
920
962
button -label "Create Set"
921
963
-width $buttonWidth
922
- -command ("unityOnCreateExportSet " + $window + " " + $namespaceField + $modelFilePath + $animFilePath + " " + $origSelection)
964
+ -command ($createExportSetCommand)
923
965
-p $buttons;
924
966
button -label "Cancel"
925
967
-width $buttonWidth
0 commit comments