Skip to content

Commit db414f7

Browse files
committed
try to guess Unity project when importing
and set the UnityProject ini variable to it if found Also remove "iconName" from macroscripts
1 parent 5ef5143 commit db414f7

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- MacroScripts that will perform actions
2-
macroScript UnityImport category:"Unity" iconName:"UnityIcons/import"
2+
macroScript UnityImport category:"Unity"
33
(
44
origObjects = #()
55

@@ -41,11 +41,29 @@ macroScript UnityImport category:"Unity" iconName:"UnityIcons/import"
4141

4242
unityFbxFilePathAttr = getFilenamePath fbxFileName
4343
unityFbxFileNameAttr = filenameFromPath fbxFileName
44-
44+
45+
-- Change Unity project if fbx is from a different Unity project.
46+
-- Get the project based on the folder structure (i.e. folder above Assets)
47+
local head = unityFbxFilePathAttr
48+
head = trimRight t "\\/"
49+
-- Check that we are not at the root directory.
50+
while head != "" and not (pathConfig.isRootPath head) do(
51+
if (pathConfig.stripPathToLeaf head) == "Assets" do (
52+
-- this is a valid Unity project, so set it
53+
unityProject = pathConfig.removePathLeaf head
54+
maxIniFile = (GetMAXIniFile())
55+
setINISetting maxIniFile "Unity" "UnityProject" unityProject
56+
57+
-- in order to break out of loop without calling break (because "break" is slow)
58+
head = ""
59+
)
60+
head = pathConfig.removePathLeaf head
61+
)
62+
4563
callbacks.removeScripts #postImport id:#unityPlugin
4664
)
4765
)
48-
macroScript UnityExport category:"Unity" iconName:"UnityIcons/export"
66+
macroScript UnityExport category:"Unity"
4967
(
5068
fn loadUnityFbxExportSettings = (
5169
fbxExportSettings = getINISetting (GetMAXIniFile()) "Unity" "UnityFbxExportSettings"

0 commit comments

Comments
 (0)