Skip to content

Commit bad29e6

Browse files
author
Benoit Hudson
committed
Fix for Autodesk-default MAYA_LOCATION on OSX.
Also made the AdskRoot a const rather than a function, and clarified the expected output of some unit tests.
1 parent edcd868 commit bad29e6

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,16 @@ public MayaVersion(string desiredVersion = "") {
3232
// If the location is given by the environment, use it.
3333
Location = System.Environment.GetEnvironmentVariable ("MAYA_LOCATION");
3434
if (!string.IsNullOrEmpty(Location)) {
35+
Location = Location.TrimEnd('/');
36+
Debug.Log("Using maya set by MAYA_LOCATION: " + Location);
3537
return;
3638
}
3739

3840
// List that directory and find the right version:
3941
// either the newest version, or the exact version we wanted.
4042
string mayaRoot = "";
4143
string bestVersion = "";
42-
var adskRoot = new System.IO.DirectoryInfo(GetAdskRoot());
44+
var adskRoot = new System.IO.DirectoryInfo(AdskRoot);
4345
foreach(var productDir in adskRoot.GetDirectories()) {
4446
var product = productDir.Name;
4547

@@ -71,22 +73,27 @@ public MayaVersion(string desiredVersion = "") {
7173
"Unable to find any version of maya. Set MAYA_LOCATION."));
7274
}
7375

74-
Location = GetAdskRoot() + "/" + mayaRoot;
76+
Location = AdskRoot + "/" + mayaRoot;
77+
if (string.IsNullOrEmpty(desiredVersion)) {
78+
Debug.Log("Using latest version of maya found in: " + Location);
79+
} else {
80+
Debug.Log(string.Format("Using maya {0} found in: {1}", desiredVersion, Location));
81+
}
7582
}
7683

7784
/// <summary>
7885
/// The path where all the different versions of Maya are installed
7986
/// by default. Depends on the platform.
8087
/// </summary>
81-
public static string GetAdskRoot() {
88+
public const string AdskRoot =
8289
#if UNITY_EDITOR_OSX
83-
return "/Applications/Autodesk";
90+
"/Applications/Autodesk"
8491
#elif UNITY_EDITOR_LINUX
85-
return "/usr/autodesk";
92+
"/usr/autodesk"
8693
#else // WINDOWS
87-
return "C:/Program Files/Autodesk";
94+
"C:/Program Files/Autodesk"
8895
#endif
89-
}
96+
;
9097

9198
/// <summary>
9299
/// The value that you might set MAYA_LOCATION to if you wanted to
@@ -100,9 +107,13 @@ public static string GetAdskRoot() {
100107
public string MayaExe {
101108
get {
102109
#if UNITY_EDITOR_OSX
103-
// MAYA_LOCATION on mac might be the app bundle itself, or
104-
// the directory in which the app bundle is stored.
105-
if (Location.EndsWith(".app")) {
110+
// MAYA_LOCATION on mac is set by Autodesk to be the
111+
// Contents directory. But let's make it easier on people
112+
// and allow just having it be the app bundle or a
113+
// directory that holds the app bundle.
114+
if (Location.EndsWith(".app/Contents")) {
115+
return Location + "/MacOS/Maya";
116+
} else if (Location.EndsWith(".app")) {
106117
return Location + "/Contents/MacOS/Maya";
107118
} else {
108119
return Location + "/Maya.app/Contents/MacOS/Maya";

Assets/FbxExporters/Editor/UnitTests/IntegrationsTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void LogNonEmptyString(string name, string str) {
2828
[Test]
2929
public void BasicTest() {
3030
// Note: This test assumes that Maya is actually installed in a default location.
31-
Assert.IsTrue(Directory.Exists(Editor.Integrations.MayaVersion.GetAdskRoot()));
31+
Assert.IsTrue(Directory.Exists(Editor.Integrations.MayaVersion.AdskRoot));
3232

3333
var maya = new Editor.Integrations.MayaVersion();
3434

@@ -38,8 +38,8 @@ public void BasicTest() {
3838

3939
Assert.IsFalse(Editor.Integrations.IsHeadlessInstall());
4040

41-
LogNonEmptyString("module path", Editor.Integrations.GetModulePath("2017"));
42-
LogNonEmptyString("module template path", Editor.Integrations.GetModuleTemplatePath("2017"));
41+
LogNonEmptyString("module path (2017)", Editor.Integrations.GetModulePath("2017"));
42+
LogNonEmptyString("module template path (2017)", Editor.Integrations.GetModuleTemplatePath("2017"));
4343
Assert.That( () => Editor.Integrations.GetModuleTemplatePath("bad version"),
4444
Throws.Exception.TypeOf<Editor.Integrations.MayaException>());
4545

0 commit comments

Comments
 (0)