Skip to content

Commit 08f75c8

Browse files
committed
handle adding UI to Max 2017
-allow user to select max 2017 in dropdown -check max version in plugin to determine if we are installing to 2017 or 2018 -add functions for getting the import/export menus
1 parent 10d680a commit 08f75c8

File tree

2 files changed

+43
-19
lines changed

2 files changed

+43
-19
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,8 @@ public override void OnInspectorGUI() {
135135
ExportSettings.DCCType foundDCC = ExportSettings.DCCType.Maya;
136136
var foundDCCPath = TryFindDCC (dccPath, ext, ExportSettings.DCCType.Maya);
137137
if (foundDCCPath == null && Application.platform == RuntimePlatform.WindowsEditor) {
138-
if (!ExportSettings.IsMax2018OrLater (dccPath)) {
139-
Debug.LogError ("3DsMax 2017 or earlier is not supported");
140-
} else {
141-
foundDCCPath = TryFindDCC (dccPath, ext, ExportSettings.DCCType.Max);
142-
foundDCC = ExportSettings.DCCType.Max;
143-
}
138+
foundDCCPath = TryFindDCC (dccPath, ext, ExportSettings.DCCType.Max);
139+
foundDCC = ExportSettings.DCCType.Max;
144140
}
145141
if (foundDCCPath == null) {
146142
Debug.LogError (string.Format ("Could not find supported DCC application at: \"{0}\"", Path.GetDirectoryName (dccPath)));
@@ -348,9 +344,6 @@ private static void FindDCCInstalls() {
348344

349345
if (product.StartsWith ("3ds max", StringComparison.InvariantCultureIgnoreCase)) {
350346
var exePath = string.Format ("{0}/{1}", productDir.FullName.Replace ("\\", "/"), "3dsmax.exe");
351-
if (!IsMax2018OrLater (exePath)) {
352-
continue;
353-
}
354347
string version = product.Substring ("3ds max ".Length);
355348
dccOptionPath.Add (exePath);
356349
dccOptionName.Add (GetUniqueName ("3ds Max " + version));

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

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,34 +83,65 @@ macroScript UnityExport category:"File-Export"
8383
)
8484
)
8585

86+
87+
fileMenuName = "&File"
88+
importMenuName = "&Import"
89+
exportMenuName = "&Export"
90+
if (maxVersion())[1] < 20000 then(
91+
importMenuName += "..."
92+
exportMenuName += "..."
93+
)
94+
95+
fn getFileSubmenuItem menuName = (
96+
foundMenuItem = undefined
97+
fileMenuItem = menuMan.findMenu fileMenuName
98+
local notFound = true
99+
if fileMenuItem != undefined then (
100+
for i=1 to fileMenuItem.numItems() while notFound do(
101+
mi = fileMenuItem.getItem i
102+
if mi.getTitle() == menuName then(
103+
foundMenuItem = mi
104+
notFound = false
105+
)
106+
)
107+
)
108+
foundMenuItem
109+
)
110+
111+
-- get the import menu
112+
fn getImportMenu = (
113+
getFileSubMenuItem importMenuName
114+
)
115+
116+
-- get the export menu
117+
fn getExportMenu = (
118+
getFileSubMenuItem exportMenuName
119+
)
120+
86121
-- Setup UI
87-
importMenuName = "File-Import"
88-
exportMenuName = "File-Export"
89122
fn setupUnityPluginUI = (
90-
importMenu = menuMan.findMenu importMenuName
91-
exportMenu = menuMan.findMenu exportMenuName
123+
importMenu = getImportMenu()
124+
exportMenu = getExportMenu()
92125
if importMenu != undefined and exportMenu != undefined do
93126
(
94127
unityImportTitle = "Import from Unity"
95128
unityExportTitle = "Export to Unity"
96129

97130
-- check if menu items already exists
98131
foundUnityImport = false
99-
for i=1 to importMenu.numItems() do(
132+
for i=1 to importMenu.numItems() while not foundUnityImport do(
100133
mi = importMenu.getItem i
101134
if mi.getTitle() == unityImportTitle then(
102135
foundUnityImport = true
103136
global unityImportAction = mi
104-
break
105137
)
106138
)
107139
foundUnityExport = false
108-
for i=1 to exportMenu.numItems() do(
140+
for i=1 to exportMenu.numItems() while not foundUnityExport do(
109141
mi = exportMenu.getItem i
110142
if mi.getTitle() == unityExportTitle then(
111143
foundUnityExport = true
112144
global unityExportAction = mi
113-
break
114145
)
115146
)
116147

@@ -139,8 +170,8 @@ setupUnityPluginUI()
139170

140171
-- Make sure that Menu gets removed at shutdown, force menu to reload each time Max is opened
141172
callbacks.addScript #preSavingMenus (
142-
"importMenu = menuMan.findMenu \""+importMenuName+"\"; \
143-
exportMenu = menuMan.findMenu \""+exportMenuName+"\"; \
173+
"importMenu = getImportMenu(); \
174+
exportMenu = getExportMenu(); \
144175
if importMenu != undefined and unityImportAction != undefined then( \
145176
importMenu.removeItem unityImportAction; \
146177
) \

0 commit comments

Comments
 (0)