Skip to content

Commit a4bb14e

Browse files
author
AustinHOME
committed
[CHANGED] the error message for if you select a broken maya.exe
[ADDED] logic for dealing with different types of osx locations for maya
1 parent ba0a14b commit a4bb14e

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,32 @@ public static string[] DCCVendorLocations {
279279
}
280280

281281
//Check the surrounding area around MAYA_LOCATION for any other Applications we may want.
282-
System.Environment.SetEnvironmentVariable("MAYA_LOCATION", "C:/Program Files/Autodesk/pickles/bin");
283282
var location = System.Environment.GetEnvironmentVariable("MAYA_LOCATION");
284283
if (!string.IsNullOrEmpty(location))
285284
{
286-
var possibleLocation = Directory.GetParent(Directory.GetParent(location).ToString());
287-
if (possibleLocation.Exists)
285+
//If we are on Windows, we need only go up one location to get to the "Autodesk" folder.
286+
var possibleLocation = Directory.GetParent(location).ToString();
287+
288+
if (Application.platform == RuntimePlatform.OSXEditor)
289+
{
290+
int appIndex = location.IndexOf("Maya.app");
291+
292+
//If we found 'Maya.app' in the location string, we're going to trim it and everything after it out
293+
//This way our possibleLocation will be more uniform between windows and mac
294+
if (appIndex != -1)
295+
{
296+
possibleLocation = location.Substring(0, (appIndex - 1));
297+
possibleLocation = Directory.GetParent(Directory.GetParent(location).ToString()).ToString();
298+
}
299+
}
300+
301+
if (Directory.Exists(possibleLocation))
288302
{
289303
locationsList.Add(possibleLocation.ToString());
290304
}
291305
}
292306

293-
if (locationsList.Count > 0)
307+
if (locationsList.Count > 0)
294308
{
295309
return locationsList.ToArray();
296310
}
@@ -561,7 +575,7 @@ private static void FindDCCInstalls() {
561575
location = location.TrimEnd('/');
562576
string pathToAdd = GetMayaExePath(location.Replace("\\", "/"));
563577
//If this path is already a part of our list, don't add it
564-
if (!dccOptionPath.Contains(pathToAdd))
578+
if (!dccOptionPath.Contains(pathToAdd) && Directory.Exists(pathToAdd))
565579
{
566580
dccOptionPath.Add(pathToAdd);
567581
dccOptionName.Add("MAYA_LOCATION");
@@ -688,14 +702,14 @@ public static void AddDCCOption(string newOption, DCCType dcc){
688702
switch (dcc) {
689703
case DCCType.Maya:
690704
var version = AskMayaVersion(newOption);
691-
if (version == null)
692-
{
693-
Debug.LogError("This version of Maya could not be launched properly");
694-
UnityEditor.EditorUtility.DisplayDialog("Error Loading 3D Application",
695-
"There was a problem loading this version of Maya",
696-
"Ok");
697-
return;
698-
}
705+
if (version == null)
706+
{
707+
Debug.LogError("This version of Maya could not be launched properly");
708+
UnityEditor.EditorUtility.DisplayDialog("Error Loading 3D Application",
709+
"Failed to add Maya option, could not get version number from maya.exe",
710+
"Ok");
711+
return;
712+
}
699713
optionName = GetUniqueDCCOptionName("Maya " + version);
700714
break;
701715
case DCCType.Max:
@@ -745,7 +759,7 @@ static string AskMayaVersion(string exePath) {
745759
}
746760
else
747761
{
748-
//This probably means we tried to launch Maya to check the version but it was some sort of fake maya.
762+
//This probably means we tried to launch Maya to check the version but it was some sort of broken maya.
749763
//We'll just return null and throw an error for it.
750764
return null;
751765
}

0 commit comments

Comments
 (0)