@@ -3,6 +3,9 @@ macroScript Import category:"Unity"
3
3
(
4
4
origObjects = #()
5
5
6
+ persistent global unityFbxFilePathAttr
7
+ persistent global unityFbxFileNameAttr
8
+
6
9
global afterImport
7
10
fn afterImport = (
8
11
unityFbxExportSet = #()
@@ -24,13 +27,19 @@ macroScript Import category:"Unity"
24
27
fbxFileName = getOpenFileName caption: " Import FBX from Unity" filename: " C:/Users/Viktoria/Desktop/" types: " FBX (*.fbx)|*.fbx|"
25
28
if fbxFileName != undefined then
26
29
(
30
+ -- reset persistent values, in case import fails
31
+ unityFbxFilePathAttr = " "
32
+ unityFbxFileNameAttr = " "
33
+
27
34
-- Get all objects in scene before importAction
28
35
origObjects = objects as array
29
- print (origObjects as string)
30
36
callbacks.addScript #postImport (" afterImport()" ) id: #unityPlugin
31
37
32
38
importFile fbxFileName using: FBXIMP
33
39
40
+ unityFbxFilePathAttr = getFilenamePath fbxFileName
41
+ unityFbxFileNameAttr = filenameFromPath fbxFileName
42
+
34
43
callbacks.removeScripts #postImport id: #unityPlugin
35
44
)
36
45
)
@@ -40,7 +49,30 @@ print "I do nothing, but I should Preview!"
40
49
)
41
50
macroScript Export category: " Unity"
42
51
(
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
+ )
44
76
)
45
77
46
78
-- Setup UI
0 commit comments