@@ -17,6 +17,83 @@ global string $UnityExportSet = "UnityFbxExportSet";
17
17
global string $UnityFbxFilePathAttr = "unityFbxFilePath";
18
18
global string $UnityFbxFileNameAttr = "unityFbxFileName";
19
19
20
+ // Load a specified settings file
21
+ proc int loadUnityFbxSettings(string $fileName, string $settingType){
22
+ // check if the file exists
23
+ if (`file -q -ex $fileName` == false){
24
+ error ("Failed to find Unity Fbx "+$settingType+" Settings at: " + $fileName);
25
+ return false;
26
+ }
27
+ eval ("source \"" + $fileName + "\"");
28
+ return true;
29
+ }
30
+
31
+
32
+ // Load the Export Settings from file
33
+ proc int loadUnityFbxExportSettings(){
34
+ $fileName = `optionVar -q "UnityFbxExportSettings"`;
35
+ return loadUnityFbxSettings($fileName, "Export");
36
+ }
37
+
38
+
39
+ // Load the Import Settings from a file
40
+ proc int loadUnityFbxImportSettings(){
41
+ $fileName = `optionVar -q "UnityFbxImportSettings"`;
42
+ return loadUnityFbxSettings($fileName, "Import");
43
+ }
44
+
45
+
46
+ proc string getAttribute(string $node, string $attr){
47
+ if (`attributeExists $attr $node`){
48
+ return `getAttr ($node + "." + $attr)`;
49
+ }
50
+ return "";
51
+ }
52
+
53
+
54
+ proc storeAttribute(string $node, string $attr, string $attrValue){
55
+ $attrType="string";
56
+ if (!attributeExists($attr, $node)){
57
+ addAttr -shortName $attr -storable true -dataType $attrType $node;
58
+ }
59
+ setAttr ($node+"."+$attr) -type $attrType $attrValue;
60
+ }
61
+
62
+
63
+ proc int setExists(string $setName){
64
+ return stringArrayContains($setName, `listSets -allSets`);
65
+ }
66
+
67
+
68
+ proc int loadUnityPlugin(string $plugin){
69
+ if (`pluginInfo -q -loaded $plugin` == false){
70
+ loadPlugin $plugin;
71
+ if (`pluginInfo -q -loaded $plugin` == false){
72
+ return false;
73
+ }
74
+ }
75
+ return true;
76
+ };
77
+
78
+
79
+ proc int loadUnityDependencies(){
80
+ // GamePipeline plugin 'SendToUnitySelection' command used in export
81
+ $pluginsToLoad = {"GamePipeline", "fbxmaya"};
82
+
83
+ $ext = "mll";
84
+ if (`about -macOS` == true){
85
+ $ext = "bundle";
86
+ }
87
+
88
+ // iterate over all the plugins, loading them with extenstion ext, and combining the results
89
+ // to return if any of the loads failed
90
+ $result = true;
91
+ for($plugin in $pluginsToLoad){
92
+ $result = $result && `loadUnityPlugin ($plugin + "." + $ext)`;
93
+ }
94
+ return $result;
95
+ }
96
+
20
97
global proc unityImport(){
21
98
// get the global variables
22
99
global string $UnityExportSet;
@@ -138,82 +215,4 @@ global proc unityExport(){
138
215
if (size($origSelection) > 0){
139
216
select -add -ne $origSelection;
140
217
}
141
- }
142
-
143
-
144
- // Load the Export Settings from file
145
- global proc int loadUnityFbxExportSettings(){
146
- $fileName = `optionVar -q "UnityFbxExportSettings"`;
147
- return loadUnityFbxSettings($fileName, "Export");
148
- }
149
-
150
-
151
- // Load the Import Settings from a file
152
- global proc int loadUnityFbxImportSettings(){
153
- $fileName = `optionVar -q "UnityFbxImportSettings"`;
154
- return loadUnityFbxSettings($fileName, "Import");
155
- }
156
-
157
-
158
- // Load a specified settings file
159
- global proc int loadUnityFbxSettings(string $fileName, string $settingType){
160
- // check if the file exists
161
- if (`file -q -ex $fileName` == false){
162
- error ("Failed to find Unity Fbx "+$settingType+" Settings at: " + $fileName);
163
- return false;
164
- }
165
- eval ("source \"" + $fileName + "\"");
166
- return true;
167
- }
168
-
169
-
170
- global proc string getAttribute(string $node, string $attr){
171
- if (`attributeExists $attr $node`){
172
- return `getAttr ($node + "." + $attr)`;
173
- }
174
- return "";
175
- }
176
-
177
-
178
- global proc storeAttribute(string $node, string $attr, string $attrValue){
179
- $attrType="string";
180
- if (!attributeExists($attr, $node)){
181
- addAttr -shortName $attr -storable true -dataType $attrType $node;
182
- }
183
- setAttr ($node+"."+$attr) -type $attrType $attrValue;
184
- }
185
-
186
-
187
- global proc int setExists(string $setName){
188
- return stringArrayContains($setName, `listSets -allSets`);
189
- }
190
-
191
-
192
- global proc int loadUnityPlugin(string $plugin){
193
- if (`pluginInfo -q -loaded $plugin` == false){
194
- loadPlugin $plugin;
195
- if (`pluginInfo -q -loaded $plugin` == false){
196
- return false;
197
- }
198
- }
199
- return true;
200
- };
201
-
202
-
203
- global proc int loadUnityDependencies(){
204
- // GamePipeline plugin 'SendToUnitySelection' command used in export
205
- $pluginsToLoad = {"GamePipeline", "fbxmaya"};
206
-
207
- $ext = "mll";
208
- if (`about -macOS` == true){
209
- $ext = "bundle";
210
- }
211
-
212
- // iterate over all the plugins, loading them with extenstion ext, and combining the results
213
- // to return if any of the loads failed
214
- $result = true;
215
- for($plugin in $pluginsToLoad){
216
- $result = $result && `loadUnityPlugin ($plugin + "." + $ext)`;
217
- }
218
- return $result;
219
218
}
0 commit comments