|
| 1 | +global string $UnityExportSet = "UnityFbxExportSet"; |
| 2 | +global string $UnityFbxFilePathAttr = "unityFbxFilePath"; |
| 3 | +global string $UnityFbxFileNameAttr = "unityFbxFileName"; |
| 4 | + |
1 | 5 | global proc unityImport(){
|
2 |
| - global string $UnityExportSet = "UnityFbxExportSet"; |
3 |
| - global string $UnityFbxFilePathAttr = "unityFbxFilePath"; |
4 |
| - global string $UnityFbxFileNameAttr = "unityFbxFileName"; |
| 6 | + // get the global variables |
| 7 | + global string $UnityExportSet; |
| 8 | + global string $UnityFbxFilePathAttr; |
| 9 | + global string $UnityFbxFileNameAttr; |
5 | 10 |
|
6 | 11 | loadUnityDependencies;
|
7 | 12 |
|
@@ -74,6 +79,66 @@ global proc unityImport(){
|
74 | 79 | }
|
75 | 80 | }
|
76 | 81 |
|
| 82 | + |
| 83 | +global proc unityExport(){ |
| 84 | + // get the global variables |
| 85 | + global string $UnityExportSet; |
| 86 | + global string $UnityFbxFilePathAttr; |
| 87 | + global string $UnityFbxFileNameAttr; |
| 88 | + |
| 89 | + if(!loadUnityDependencies()){ |
| 90 | + return; |
| 91 | + } |
| 92 | + |
| 93 | + if(!loadUnityFbxExportSettings()){ |
| 94 | + return; |
| 95 | + } |
| 96 | + |
| 97 | + // select the export set for export, if it exists, |
| 98 | + // otherwise take what is currently selected |
| 99 | + $origSelection = `ls -sl`; |
| 100 | + if (setExists($UnityExportSet)){ |
| 101 | + select -r -ne $UnityExportSet; |
| 102 | + } |
| 103 | + |
| 104 | + $unity_fbx_file_path = getAttribute($UnityExportSet, $UnityFbxFilePathAttr); |
| 105 | + $unity_fbx_file_name = getAttribute($UnityExportSet, $UnityFbxFileNameAttr); |
| 106 | + |
| 107 | + $strCmd = ""; |
| 108 | + if ($unity_fbx_file_path != "" && $unity_fbx_file_name != ""){ |
| 109 | + $strCmd = "file -force -options \"\" -typ \"FBX export\" -pr -es \"" + $unity_fbx_file_path + "/" + $unity_fbx_file_name + "\""; |
| 110 | + } |
| 111 | + else { |
| 112 | + $strCmd = "SendToUnitySelection"; |
| 113 | + } |
| 114 | + eval $strCmd; |
| 115 | + |
| 116 | + select -cl; |
| 117 | + if (size($origSelection) > 0){ |
| 118 | + select -add -ne $origSelection; |
| 119 | + } |
| 120 | +} |
| 121 | + |
| 122 | +// Load the Export Settings from file |
| 123 | +global proc int loadUnityFbxExportSettings(){ |
| 124 | + $fileName = `optionVar -q "UnityFbxExportSettings"`; |
| 125 | + |
| 126 | + // check if the file exists |
| 127 | + if (`file -q -ex $fileName` == false){ |
| 128 | + error ("Failed to find Unity Fbx Export Settings at: " + $fileName); |
| 129 | + return false; |
| 130 | + } |
| 131 | + eval ("source \"" + $fileName + "\""); |
| 132 | + return true; |
| 133 | +} |
| 134 | + |
| 135 | +global proc string getAttribute(string $node, string $attr){ |
| 136 | + if (`attributeExists $attr $node`){ |
| 137 | + return `getAttr ($node + "." + $attr)`; |
| 138 | + } |
| 139 | + return ""; |
| 140 | +} |
| 141 | + |
77 | 142 | global proc storeAttribute(string $node, string $attr, string $attrValue){
|
78 | 143 | $attrType="string";
|
79 | 144 | if (!attributeExists($attr, $node)){
|
|
0 commit comments