Skip to content

Commit 788c2e6

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-30029-sprint32-release
2 parents a6ee764 + 3af99cd commit 788c2e6

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

Assets/Integrations/Autodesk/max/scripts/UnityFbxForMaxPlugin.ms

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ macroScript UnityImport category:"Unity"
55

66
persistent global unityFbxFilePathAttr
77
persistent global unityFbxFileNameAttr
8+
persistent global unityAskSetUnits
89

910
global afterImport
1011
fn afterImport = (
@@ -29,6 +30,24 @@ macroScript UnityImport category:"Unity"
2930
fbxFileName = getOpenFileName caption:"Import FBX from Unity" filename:(unityProjectPath + "/Assets/") types:"FBX (*.fbx)|*.fbx|"
3031
if fbxFileName != undefined then
3132
(
33+
-- ask to set units to cm if not already
34+
if (unityAskSetUnits == undefined or not unityAskSetUnits) and units.SystemType != #Centimeters then (
35+
result = false
36+
message = ("Detected system units set to "+units.SystemType+".\n\n" +
37+
"Using system units other than centimeters is not recommended for the Unity FBX " +
38+
"workflow and may result in unexpected scaling on export.\n\n" +
39+
"Would you like to change the system units to centimeters?")
40+
(
41+
result = queryBox message title:"Warning, system units not set to centimeters"
42+
)
43+
if result then (
44+
units.SystemType = #Centimeters
45+
)
46+
else (
47+
unityAskSetUnits = true
48+
)
49+
)
50+
3251
-- reset persistent values, in case import fails
3352
unityFbxFilePathAttr = ""
3453
unityFbxFileNameAttr = ""
@@ -65,12 +84,25 @@ macroScript UnityImport category:"Unity"
6584
)
6685
macroScript UnityExport category:"Unity"
6786
(
87+
fn unitToScaleFactor unit = (
88+
case unit of (
89+
#Inches: 2.54
90+
#Feet: 30.48
91+
#Miles: 160934
92+
#Millimeters: 0.1
93+
#Kilometers: 100000
94+
#Meters: 100
95+
default: 1
96+
)
97+
);
98+
6899
fn loadUnityFbxExportSettings = (
69100
fbxExportSettings = getINISetting (GetMAXIniFile()) "Unity" "UnityFbxExportSettings"
70101
if fbxExportSettings != undefined and doesFileExist fbxExportSettings then(
71102
filein fbxExportSettings
72103
)
73-
)
104+
FbxExporterSetParam "ScaleFactor" (unitToScaleFactor units.SystemType)
105+
);
74106

75107
-- Make sure the FbxExporter plugin is loaded
76108
pluginManager.loadClass FbxExporter
@@ -83,6 +115,9 @@ macroScript UnityExport category:"Unity"
83115
select exportSet
84116
)
85117

118+
local origUnits = units.SystemType
119+
units.SystemType = #Centimeters
120+
86121
exportFileName = undefined
87122
if unityFbxFilePathAttr != undefined and unityFbxFileNameAttr != undefined then(
88123
exportFileName = unityFbxFilePathAttr + unityFbxFileNameAttr
@@ -96,6 +131,8 @@ macroScript UnityExport category:"Unity"
96131
exportFile exportFileName #noPrompt selectedOnly:true using:FBXEXP
97132
)
98133

134+
units.SystemType = origUnits
135+
99136
if origSelection != undefined then (
100137
select origSelection
101138
)

Assets/Integrations/Autodesk/max/scripts/unityFbxExportSettings.ms

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ FbxExporterSetParam "Lights" true
1717
FbxExporterSetParam "EmbedTextures" false
1818

1919
-- Units
20-
--FbxExporterSetParam "ScaleFactor" 1
20+
FbxExporterSetParam "ScaleFactor" 1
2121
FbxExporterSetParam "ConvertUnit" "cm"
2222

2323
-- Axis Conversion

0 commit comments

Comments
 (0)