Skip to content

Commit 512f696

Browse files
committed
create multi file import dialog
1 parent 70d4f0a commit 512f696

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,37 @@ macroScript UnityImport category:"Unity" tooltip:"Import an FBX file from a Unit
3030
)
3131
);
3232

33+
-- allow multiple files to be selected for import
34+
fn GetMultiOpenFilenames caption:"Open" filename:"" types:"All Files (*.*)|*.*" default:1 =
35+
(
36+
local dialog = DotNetObject "System.Windows.Forms.OpenFileDialog"
37+
dialog.multiSelect = true
38+
dialog.title = caption
39+
40+
if doesFileExist filename then
41+
dialog.initialDirectory = filename
42+
43+
dialog.filter = types
44+
dialog.filterIndex = default
45+
46+
local result = dialog.ShowDialog()
47+
if (result.Equals result.OK) then
48+
dialog.filenames
49+
else
50+
undefined
51+
)
52+
53+
3354
-- Make sure the FbxImporter plugin is loaded
3455
pluginManager.loadClass FbxImporter
3556

3657
loadUnityFbxImportSettings()
3758

3859
unityProjectPath = getINISetting (GetMAXIniFile()) "Unity" "UnityProject"
39-
fbxFileName = getOpenFileName caption:"Import FBX from Unity" filename:(unityProjectPath + "/Assets/") types:"FBX (*.fbx)|*.fbx|"
40-
if fbxFileName != undefined then
60+
local unityAssetsPath = (unityProjectPath + "/Assets/")
61+
unityAssetsPath = substituteString unityAssetsPath "/" "\\" -- dot net class requires backspaces
62+
local fbxFileNames = getMultiOpenFilenames caption:"Import FBX from Unity" filename:unityAssetsPath types:"FBX (*.fbx)|*.fbx"
63+
if fbxFileNames != undefined then
4164
(
4265
-- ask to set units to cm if not already
4366
if (unityAskSetUnits == undefined or not unityAskSetUnits) and units.SystemType != #Centimeters then (

0 commit comments

Comments
 (0)