Skip to content

Commit fef551a

Browse files
committed
in max 2017 add a separate unity menu to the menu bar
1 parent b2f2b7c commit fef551a

File tree

1 file changed

+56
-8
lines changed

1 file changed

+56
-8
lines changed

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

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,21 @@ macroScript UnityExport category:"Unity" iconName:"UnityIcons/export"
8383
)
8484
)
8585

86+
fn createUnityActionItem macroName category title parentMenu = (
87+
local unityAction = menuMan.createActionItem macroName category; --create an ActionItem from the MacroScript
88+
unityAction.setTitle title;
89+
unityAction.setUseCustomTitle true;
90+
parentMenu.addItem unityAction -1;
91+
unityAction
92+
);
93+
94+
fn createUnityImportAction title parentMenu = (
95+
createUnityActionItem "UnityImport" "Unity" title parentMenu;
96+
);
97+
98+
fn createUnityExportAction title parentMenu = (
99+
createUnityActionItem "UnityExport" "Unity" title parentMenu;
100+
);
86101

87102
-- Setup UI using menu manager if using 3ds Max 2018+
88103
if (maxVersion())[1] >= 20000 then(
@@ -131,16 +146,10 @@ if (maxVersion())[1] >= 20000 then(
131146
if menuMan.registerMenuContext id[1] then
132147
(
133148
if foundUnityImport == false do (
134-
global unityImportAction = menuMan.createActionItem "UnityImport" "Unity"; --create an ActionItem from the MacroScript
135-
unityImportAction.setTitle unityImportTitle;
136-
unityImportAction.setUseCustomTitle true;
137-
importMenu.addItem unityImportAction -1; --add the ActionItem to the menu
149+
global unityImportAction = createUnityImportAction unityImportTitle importMenu
138150
)
139151
if foundUnityExport == false do (
140-
global unityExportAction = menuMan.createActionItem "UnityExport" "Unity";
141-
unityExportAction.setTitle unityExportTitle;
142-
unityExportAction.setUseCustomTitle true;
143-
exportMenu.addItem unityExportAction -1;
152+
global unityExportAction = createUnityExportAction unityExportTitle exportMenu
144153
)
145154
menuMan.updateMenuBar() --update the menu bar
146155
)
@@ -160,4 +169,43 @@ if (maxVersion())[1] >= 20000 then(
160169
exportMenu.removeItem unityExportAction; \
161170
)"
162171
)
172+
)
173+
else(
174+
-- for 3ds Max 2017
175+
176+
unityMenuName = "Unity"
177+
178+
fn getUnityMenu = (
179+
menuMan.findMenu unityMenuName
180+
);
181+
182+
-- Setup UI
183+
fn setupUnityPluginUI = (
184+
unityMenu = getUnityMenu()
185+
unityImportTitle = "Import"
186+
unityExportTitle = "Export"
187+
if unityMenu != undefined do
188+
(
189+
-- remove the menu if it still exists
190+
menuMan.unRegisterMenu unityMenu
191+
)
192+
193+
id = genClassID returnValue:true
194+
if menuMan.registerMenuContext id[1] then
195+
(
196+
createUnityImportAction unityImportTitle unityMenu
197+
createUnityExportAction unityExportTitle unityMenu
198+
199+
menuMan.updateMenuBar() --update the menu bar
200+
)
201+
);
202+
setupUnityPluginUI()
203+
204+
-- Make sure that Menu gets removed at shutdown, force menu to reload each time Max is opened
205+
callbacks.addScript #preSavingMenus (
206+
"unityMenu = getUnityMenu(); \
207+
if unityMenu != undefined then( \
208+
menuMan.unRegisterMenu unityMenu; \
209+
)"
210+
)
163211
)

0 commit comments

Comments
 (0)