Skip to content

Commit 3800f84

Browse files
committed
set Unity Project path in 3dsmax.ini
- while copying the maxscript to the correct location, also save the unity project path into the 3dsmax ini file - use a ms file for this instead of hardcoding it into C#
1 parent 9c63379 commit 3800f84

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -395,14 +395,11 @@ class MaxIntegration
395395
private const string PluginName = "unityOneClickPlugin.ms";
396396
private const string PluginPath = "FbxExporters/Integrations/Autodesk/max/scripts/" + PluginName;
397397

398-
private const string InstallMaxScriptTemplate =
399-
@"temp = pathConfig.GetDir(#userStartupScripts) + \""/{UnityPluginScript_Name}\"";" +
400-
@"deleteFile temp;" +
401-
@"copyFile \""{UnityPluginScript_Source}\"" temp;" +
402-
@"quitMax()";
398+
private const string ConfigureMaxScript = "FbxExporters/Integrations/Autodesk/max/scripts/configureUnityFbxForMax.ms";
403399

404-
private const string PluginSourceTag = "{UnityPluginScript_Source}";
405-
private const string PluginNameTag = "{UnityPluginScript_Name}";
400+
private const string PluginSourceTag = "UnityPluginScript_Source";
401+
private const string PluginNameTag = "UnityPluginScript_Name";
402+
private const string ProjectTag = "UnityProject";
406403

407404
// TODO: get this from the export settings
408405
private static string GetMaxExe(){
@@ -413,13 +410,16 @@ private static string GetInstallScript(){
413410
Dictionary<string,string> Tokens = new Dictionary<string,string>()
414411
{
415412
{PluginSourceTag, (Application.dataPath + "/" + PluginPath) },
416-
{PluginNameTag, PluginName }
413+
{PluginNameTag, PluginName },
414+
{ProjectTag, Integrations.GetProjectPath()}
417415
};
418416

419-
var installScript = InstallMaxScriptTemplate;
417+
var installScript = "";
418+
// setup the variables to be used in the configure max script
420419
foreach (var t in Tokens) {
421-
installScript = installScript.Replace (t.Key, t.Value);
420+
installScript += string.Format (@"global {0} = @\""{1}\"";", t.Key, t.Value);
422421
}
422+
installScript += string.Format(@"filein \""{0}/{1}\""", Application.dataPath, ConfigureMaxScript);
423423
return installScript;
424424
}
425425

@@ -476,7 +476,7 @@ public static void InstallIntegration()
476476
message = string.Format("Failed to configure 3DsMax, please check logs (exitcode={0}).", exitCode);
477477
} else {
478478
title = "Completed installation of 3DsMax Integration.";
479-
message = "Enjoy the new \"Unity\" menu in 3DsMax.";
479+
message = "Enjoy the new Unity menu in 3DsMax.";
480480
}
481481
UnityEditor.EditorUtility.DisplayDialog (title, message, "Ok");
482482
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
temp = pathConfig.GetDir(#userStartupScripts) + "/" + UnityPluginScript_Name;
2+
deleteFile temp;
3+
copyFile UnityPluginScript_Source temp;
4+
5+
setINISetting (GetMAXIniFile()) "Unity" "UnityProject" UnityProject
6+
7+
quitMax()

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ macroScript Import category:"Unity"
2424

2525
-- Make sure the FbxImporter plugin is loaded
2626
pluginManager.loadClass FbxImporter
27-
fbxFileName = getOpenFileName caption:"Import FBX from Unity" filename:"C:/Users/Viktoria/Desktop/" types:"FBX (*.fbx)|*.fbx|"
27+
28+
unityProjectPath = getINISetting (GetMAXIniFile()) "Unity" "UnityProject"
29+
fbxFileName = getOpenFileName caption:"Import FBX from Unity" filename:unityProjectPath types:"FBX (*.fbx)|*.fbx|"
2830
if fbxFileName != undefined then
2931
(
3032
-- reset persistent values, in case import fails

0 commit comments

Comments
 (0)