@@ -83,6 +83,21 @@ macroScript UnityExport category:"Unity" iconName:"UnityIcons/export"
83
83
)
84
84
)
85
85
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
+ );
86
101
87
102
-- Setup UI using menu manager if using 3ds Max 2018+
88
103
if (maxVersion())[1 ] >= 20000 then (
@@ -131,16 +146,10 @@ if (maxVersion())[1] >= 20000 then(
131
146
if menuMan.registerMenuContext id[1 ] then
132
147
(
133
148
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
138
150
)
139
151
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
144
153
)
145
154
menuMan.updateMenuBar() -- update the menu bar
146
155
)
@@ -160,4 +169,43 @@ if (maxVersion())[1] >= 20000 then(
160
169
exportMenu.removeItem unityExportAction; \
161
170
)"
162
171
)
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
+ )
163
211
)
0 commit comments