@@ -101,56 +101,55 @@ fn createUnityExportAction title parentMenu = (
101
101
102
102
-- Setup UI using menu manager if using 3ds Max 2018+
103
103
if (maxVersion())[1 ] >= 20000 then (
104
- importMenuName = " File-Import"
105
- exportMenuName = " File-Export"
104
+ global importMenuName = " File-Import"
105
+ global exportMenuName = " File-Export"
106
106
107
107
-- get the import menu
108
+ global getImportMenu
108
109
fn getImportMenu = (
109
110
menuMan.findMenu importMenuName
110
111
)
111
112
112
113
-- get the export menu
114
+ global getExportMenu
113
115
fn getExportMenu = (
114
116
menuMan.findMenu exportMenuName
115
117
)
116
118
117
119
-- Setup UI
118
120
fn setupUnityPluginUI = (
119
- importMenu = getImportMenu()
120
- exportMenu = getExportMenu()
121
+ local importMenu = getImportMenu()
122
+ local exportMenu = getExportMenu()
121
123
if importMenu != undefined and exportMenu != undefined do
122
124
(
123
- unityImportTitle = " Import from Unity"
124
- unityExportTitle = " Export to Unity"
125
+ local unityImportTitle = " Import from Unity"
126
+ local unityExportTitle = " Export to Unity"
125
127
126
- -- check if menu items already exists
127
- foundUnityImport = false
128
+ -- check if menu items already exist, delete if they do
129
+ local foundUnityImport = false
128
130
for i= 1 to importMenu.numItems() while not foundUnityImport do (
129
- mi = importMenu.getItem i
131
+ local mi = importMenu.getItem i
130
132
if mi.getTitle() == unityImportTitle then (
133
+ importMenu.removeItem mi
131
134
foundUnityImport = true
132
- global unityImportAction = mi
133
135
)
134
136
)
135
- foundUnityExport = false
137
+ local foundUnityExport = false
136
138
for i= 1 to exportMenu.numItems() while not foundUnityExport do (
137
- mi = exportMenu.getItem i
139
+ local mi = exportMenu.getItem i
138
140
if mi.getTitle() == unityExportTitle then (
141
+ exportMenu.removeItem mi
139
142
foundUnityExport = true
140
- global unityExportAction = mi
141
143
)
142
144
)
143
145
144
146
if foundUnityImport == false or foundUnityExport == false then (
145
147
id = genClassID returnValue: true
146
148
if menuMan.registerMenuContext id[1 ] then
147
149
(
148
- if foundUnityImport == false do (
149
- global unityImportAction = createUnityImportAction unityImportTitle importMenu
150
- )
151
- if foundUnityExport == false do (
152
- global unityExportAction = createUnityExportAction unityExportTitle exportMenu
153
- )
150
+ global unityImportAction = createUnityImportAction unityImportTitle importMenu
151
+ global unityExportAction = createUnityExportAction unityExportTitle exportMenu
152
+
154
153
menuMan.updateMenuBar() -- update the menu bar
155
154
)
156
155
)
@@ -173,17 +172,18 @@ if (maxVersion())[1] >= 20000 then(
173
172
else (
174
173
-- for 3ds Max 2017
175
174
176
- unityMenuName = " Unity"
175
+ global unityMenuName = " Unity"
177
176
177
+ global getUnityMenu
178
178
fn getUnityMenu = (
179
179
menuMan.findMenu unityMenuName
180
180
);
181
181
182
182
-- Setup UI
183
183
fn setupUnityPluginUI = (
184
- unityMenu = getUnityMenu()
185
- unityImportTitle = " Import"
186
- unityExportTitle = " Export"
184
+ local unityMenu = getUnityMenu()
185
+ local unityImportTitle = " Import"
186
+ local unityExportTitle = " Export"
187
187
if unityMenu != undefined do
188
188
(
189
189
-- remove the menu if it still exists
@@ -193,6 +193,11 @@ else(
193
193
id = genClassID returnValue: true
194
194
if menuMan.registerMenuContext id[1 ] then
195
195
(
196
+ local mainMenuBar = menuMan.getMainMenuBar()
197
+ local unityMenu = menuMan.createMenu unityMenuName
198
+ local unityMenuItem = menuMan.createSubMenuItem unityMenuName unityMenu
199
+ mainMenuBar.addItem unityMenuItem - 1
200
+
196
201
createUnityImportAction unityImportTitle unityMenu
197
202
createUnityExportAction unityExportTitle unityMenu
198
203
@@ -204,7 +209,7 @@ else(
204
209
-- Make sure that Menu gets removed at shutdown, force menu to reload each time Max is opened
205
210
callbacks.addScript #preSavingMenus (
206
211
" unityMenu = getUnityMenu(); \
207
- if unityMenu != undefined then ( \
212
+ if unityMenu != undefined do ( \
208
213
menuMan.unRegisterMenu unityMenu; \
209
214
)"
210
215
)
0 commit comments