Skip to content

Commit 9c63379

Browse files
committed
UNI-27558 recreate export button in Max
-store imported filename into persistent global variables (stored and loaded into .max scenes)
1 parent 0adf3db commit 9c63379

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

Assets/FbxExporters/Integrations/Autodesk/max/scripts/unityOneClickPlugin.ms

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ macroScript Import category:"Unity"
33
(
44
origObjects = #()
55

6+
persistent global unityFbxFilePathAttr
7+
persistent global unityFbxFileNameAttr
8+
69
global afterImport
710
fn afterImport = (
811
unityFbxExportSet = #()
@@ -24,13 +27,19 @@ macroScript Import category:"Unity"
2427
fbxFileName = getOpenFileName caption:"Import FBX from Unity" filename:"C:/Users/Viktoria/Desktop/" types:"FBX (*.fbx)|*.fbx|"
2528
if fbxFileName != undefined then
2629
(
30+
-- reset persistent values, in case import fails
31+
unityFbxFilePathAttr = ""
32+
unityFbxFileNameAttr = ""
33+
2734
-- Get all objects in scene before importAction
2835
origObjects = objects as array
29-
print (origObjects as string)
3036
callbacks.addScript #postImport ("afterImport()") id:#unityPlugin
3137

3238
importFile fbxFileName using:FBXIMP
3339

40+
unityFbxFilePathAttr = getFilenamePath fbxFileName
41+
unityFbxFileNameAttr = filenameFromPath fbxFileName
42+
3443
callbacks.removeScripts #postImport id:#unityPlugin
3544
)
3645
)
@@ -40,7 +49,30 @@ print "I do nothing, but I should Preview!"
4049
)
4150
macroScript Export category:"Unity"
4251
(
43-
print "I do nothing, but I should Export!"
52+
-- Make sure the FbxExporter plugin is loaded
53+
pluginManager.loadClass FbxExporter
54+
55+
origSelection = getCurrentSelection()
56+
exportSet = selectionSets["UnityFbxExportSet"]
57+
if not isdeleted exportSet and exportSet != undefined then(
58+
select exportSet
59+
)
60+
61+
exportFileName = undefined
62+
if unityFbxFilePathAttr != undefined and unityFbxFileNameAttr != undefined then(
63+
exportFileName = unityFbxFilePathAttr + unityFbxFileNameAttr
64+
)
65+
else(
66+
exportFileName = getSaveFileName caption:"Export FBX to Unity" filename:"C:/Users/Viktoria/Desktop/" types:"FBX (*.fbx)|*.fbx|"
67+
)
68+
69+
if exportFileName != undefined then (
70+
exportFile exportFileName selectedOnly:true using:FBXEXP
71+
)
72+
73+
if origSelection != undefined then (
74+
select origSelection
75+
)
4476
)
4577

4678
-- Setup UI

0 commit comments

Comments
 (0)