@@ -5,11 +5,49 @@ global string $UnityFbxAnimFileNameAttr = "unityFbxAnimFileName";
5
5
global string $UnityFbxNamespaceAttr = "unityFbxNamespace";
6
6
global string $UnityExportSetNameFormat = "^1s_UnityExportSet";
7
7
8
- // global string $UnityModuleName = "UnityFbxForMaya";
8
+ global string $UnityModuleName = "UnityFbxForMaya";
9
+
10
+ global string $UnityImportSettingsOptionVar = "UnityFbxImportSettings";
11
+ global string $UnityExportSettingsOptionVar = "UnityFbxExportSettings";
9
12
10
13
global string $UnityDefaultImportSettingsFileName = "unityFbxImportSettings.mel";
11
14
global string $UnityDefaultExportSettingsFileName = "unityFbxExportSettings.mel";
12
15
16
+ global string $UnityDefaultImportSettings = "\
17
+ FBXResetImport;\n\
18
+ FBXImportAxisConversionEnable -v true;\n\
19
+ FBXImportCameras -v true;\n\
20
+ FBXImportLights -v true;\n\
21
+ FBXImportSetTake -takeIndex -1;\n\
22
+ // Add and update animation\n\
23
+ FBXImportMode -v merge;";
24
+
25
+ global string $UnityDefaultExportSettings = "\
26
+ FBXResetExport;\n\
27
+ // FBX file format\n\
28
+ FBXExportInAscii -v false;\n\
29
+ FBXExportFileVersion -v FBX201600;\n\
30
+ \n\
31
+ // Geometry\n\
32
+ FBXExportSmoothMesh -v false;\n\
33
+ FBXExportInstances -v true;\n\
34
+ FBXExportReferencedAssetsContent -v false;\n\
35
+ \n\
36
+ // Animation\n\
37
+ FBXExportAnimationOnly -v false;\n\
38
+ \n\
39
+ FBXExportCameras -v true;\n\
40
+ FBXExportLights -v true;\n\
41
+ \n\
42
+ FBXExportEmbeddedTextures -v false;\n\
43
+ \n\
44
+ // Units\n\
45
+ FBXExportScaleFactor 1;\n\
46
+ FBXExportConvertUnitString cm;\n\
47
+ \n\
48
+ // Axis Conversion\n\
49
+ FBXExportUpAxis y;";
50
+
13
51
global int $UnityFbxFilePathIndex = 0;
14
52
global int $UnityFbxFileNameIndex = 1;
15
53
global int $UnityFbxAnimFilePathIndex = 2;
@@ -30,13 +68,34 @@ global proc unityRemoveNativeMenuOnLoad(){
30
68
}
31
69
32
70
// Load a specified settings file
33
- proc int loadUnityFbxSettings(string $fileName, string $settingType){
71
+ proc int loadUnityFbxSettings(string $settingType, string $optionVarName, string $defaultSettingsFileName, string $defaultSettings){
72
+ global string $UnityModuleName;
73
+
74
+ $fileName = `optionVar -q $optionVarName`;
75
+
76
+ // if no filename set (optionVar cleared), reset it to default filename
77
+ if ($fileName == 0){
78
+ $modulePath = `moduleInfo -moduleName $UnityModuleName -path`;
79
+ // {$modulePath}/scripts/{$defaultSettingsFileName}
80
+ $modulePath = $modulePath + "/scripts/" + $defaultSettingsFileName;
81
+
82
+ $fileName = $modulePath;
83
+ optionVar -stringValue $optionVarName $fileName;
84
+ }
85
+
34
86
// check if the file exists
35
87
if (`file -q -ex $fileName` == false){
36
- //error ("Failed to find Unity Fbx "+$settingType+" Settings at: " + $fileName);
37
- //return false;
38
-
39
88
// create file with default settings
89
+ $fileId = `fopen $fileName "w"`;
90
+ fprint $fileId $defaultSettings;
91
+ fclose $fileId;
92
+ }
93
+
94
+ // if the file still doesn't exist (failed to create)
95
+ // print an error message.
96
+ if (`file -q -ex $fileName` == false){
97
+ error ("Failed to find Unity Fbx "+$settingType+" Settings at: " + $fileName);
98
+ return false;
40
99
}
41
100
42
101
eval ("source \"" + $fileName + "\"");
@@ -46,23 +105,29 @@ proc int loadUnityFbxSettings(string $fileName, string $settingType){
46
105
47
106
// Load the Export Settings from file
48
107
proc int loadUnityFbxExportSettings(){
49
- $fileName = `optionVar -q "UnityFbxExportSettings"`;
50
- return loadUnityFbxSettings($fileName, "Export");
108
+ global string $UnityExportSettingsOptionVar;
109
+ global string $UnityDefaultExportSettings;
110
+ global string $UnityDefaultExportSettingsFileName;
111
+ return loadUnityFbxSettings(
112
+ "Export",
113
+ $UnityExportSettingsOptionVar,
114
+ $UnityDefaultExportSettingsFileName,
115
+ $UnityDefaultExportSettings
116
+ );
51
117
}
52
118
53
119
54
120
// Load the Import Settings from a file
55
121
proc int loadUnityFbxImportSettings(){
56
- $fileName = `optionVar -q "UnityFbxImportSettings"`;
57
-
58
- // if no filename set (optionVar cleared), reset it to default filename
59
- if ($fileName == 0){
60
- //$modulePath = `moduleInfo -moduleName $UnityModuleName -path`;
61
- // {$modulePath}/scripts/{$UnityDefaultImportSettingsFileName}
62
-
63
- }
64
-
65
- return loadUnityFbxSettings($fileName, "Import");
122
+ global string $UnityImportSettingsOptionVar;
123
+ global string $UnityDefaultImportSettings;
124
+ global string $UnityDefaultImportSettingsFileName;
125
+ return loadUnityFbxSettings(
126
+ "Import",
127
+ $UnityImportSettingsOptionVar,
128
+ $UnityDefaultImportSettingsFileName,
129
+ $UnityDefaultImportSettings
130
+ );
66
131
}
67
132
68
133
0 commit comments