Skip to content

Commit e7b2497

Browse files
committed
add function for loading FBX import settings
+ added import settings mel file + remove unused values from configureUnityFbxForMayaLT
1 parent 0f3501f commit e7b2497

File tree

4 files changed

+74
-5
lines changed

4 files changed

+74
-5
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
global proc configureUnityFbxForMayaLT(
2+
string $unityProject,
3+
string $unityFbxExportSettings,
4+
string $unityFbxImportSettings,
5+
int $headless)
6+
{
7+
// configure plugin settings
8+
optionVar -stringValue "UnityProject" $unityProject;
9+
optionVar -stringValue "UnityFbxExportSettings" $unityFbxExportSettings;
10+
optionVar -stringValue "UnityFbxImportSettings" $unityFbxImportSettings;
11+
optionVar -intValue "UnityFbxForMaya_Headless" $headless;
12+
13+
return;
14+
}

Assets/Integrations/Autodesk/mayalt/scripts/unityCommands.mel

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ global proc unityImport(){
88
global string $UnityFbxFilePathAttr;
99
global string $UnityFbxFileNameAttr;
1010

11-
loadUnityDependencies;
11+
if(!loadUnityDependencies()){
12+
error("Failed to load Unity dependencies");
13+
return;
14+
}
15+
16+
if(!loadUnityFbxImportSettings()){
17+
return;
18+
}
1219

1320
$unityProject = `optionVar -q "UnityProject"`;
1421

1522
$filePath = `fileDialog2 -dialogStyle 2 -caption "FBX Import" -dir ($unityProject + "/Assets") -fileFilter "*.fbx" -selectFileFilter "FBX" -fileMode 1`;
1623

17-
print $filePath;
18-
1924
// store path and filename
2025
if(size($filePath) <= 0){
2126
return;
@@ -120,26 +125,41 @@ global proc unityExport(){
120125
}
121126
}
122127

128+
123129
// Load the Export Settings from file
124130
global proc int loadUnityFbxExportSettings(){
125131
$fileName = `optionVar -q "UnityFbxExportSettings"`;
126-
132+
return loadUnityFbxSettings($fileName, "Export");
133+
}
134+
135+
136+
// Load the Import Settings from a file
137+
global proc int loadUnityFbxImportSettings(){
138+
$fileName = `optionVar -q "UnityFbxImportSettings"`;
139+
return loadUnityFbxSettings($fileName, "Import");
140+
}
141+
142+
143+
// Load a specified settings file
144+
global proc int loadUnityFbxSettings(string $fileName, string $settingType){
127145
// check if the file exists
128146
if (`file -q -ex $fileName` == false){
129-
error ("Failed to find Unity Fbx Export Settings at: " + $fileName);
147+
error ("Failed to find Unity Fbx "+$settingType+" Settings at: " + $fileName);
130148
return false;
131149
}
132150
eval ("source \"" + $fileName + "\"");
133151
return true;
134152
}
135153

154+
136155
global proc string getAttribute(string $node, string $attr){
137156
if (`attributeExists $attr $node`){
138157
return `getAttr ($node + "." + $attr)`;
139158
}
140159
return "";
141160
}
142161

162+
143163
global proc storeAttribute(string $node, string $attr, string $attrValue){
144164
$attrType="string";
145165
if (!attributeExists($attr, $node)){
@@ -148,10 +168,12 @@ global proc storeAttribute(string $node, string $attr, string $attrValue){
148168
setAttr ($node+"."+$attr) -type $attrType $attrValue;
149169
}
150170

171+
151172
global proc int setExists(string $setName){
152173
return stringArrayContains($setName, `listSets -allSets`);
153174
}
154175

176+
155177
global proc int loadUnityPlugin(string $plugin){
156178
if (`pluginInfo -q -loaded $plugin` == false){
157179
loadPlugin $plugin;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
FBXResetExport;
2+
3+
// FBX file format
4+
FBXExportInAscii -v false;
5+
FBXExportFileVersion -v FBX201600;
6+
7+
// Geometry
8+
FBXExportSmoothMesh -v false;
9+
FBXExportInstances -v true;
10+
FBXExportReferencedAssetsContent -v false;
11+
12+
// Animation
13+
FBXExportAnimationOnly -v false;
14+
15+
FBXExportCameras -v true;
16+
FBXExportLights -v true;
17+
18+
FBXExportEmbeddedTextures -v false;
19+
20+
// Units
21+
FBXExportScaleFactor 1;
22+
FBXExportConvertUnitString cm;
23+
24+
// Axis Conversion
25+
FBXExportUpAxis y;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FBXResetImport;
2+
3+
FBXImportAxisConversionEnable -v true;
4+
FBXImportCameras -v true;
5+
FBXImportLights -v true;
6+
7+
// Add and update animation
8+
FBXImportMode -v merge;

0 commit comments

Comments
 (0)