Skip to content

Commit 283951d

Browse files
authored
Merge pull request #191 from Unity-Technologies/UNI-29979-max-configure-unity-project
Uni 29979 max configure unity project on import
2 parents c40d269 + cc4aa14 commit 283951d

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,25 @@ macroScript UnityImport category:"Unity"
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 head "\\/"
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
)

0 commit comments

Comments
 (0)