Skip to content

Commit ba0a14b

Browse files
author
AJubrey
committed
[ADDED] a check so that we query the location of MAYA_LOCATION for other possible DCC's
[ADDED] some comments [CHANGED] made it so that the part of the code that catches broken Maya files throws an error to the user
1 parent c6417ea commit ba0a14b

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,25 @@ public static string[] DCCVendorLocations {
276276
locationsList.Add(locations[i]);
277277
}
278278
}
279-
if (locationsList.Count > 0)
279+
}
280+
281+
//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");
283+
var location = System.Environment.GetEnvironmentVariable("MAYA_LOCATION");
284+
if (!string.IsNullOrEmpty(location))
285+
{
286+
var possibleLocation = Directory.GetParent(Directory.GetParent(location).ToString());
287+
if (possibleLocation.Exists)
280288
{
281-
return locationsList.ToArray();
289+
locationsList.Add(possibleLocation.ToString());
282290
}
283291
}
284292

293+
if (locationsList.Count > 0)
294+
{
295+
return locationsList.ToArray();
296+
}
297+
285298
switch (Application.platform)
286299
{
287300
case RuntimePlatform.WindowsEditor:
@@ -546,8 +559,13 @@ private static void FindDCCInstalls() {
546559
if (!string.IsNullOrEmpty(location))
547560
{
548561
location = location.TrimEnd('/');
549-
dccOptionPath.Add(GetMayaExePath(location.Replace("\\", "/")));
550-
dccOptionName.Add("MAYA_LOCATION");
562+
string pathToAdd = GetMayaExePath(location.Replace("\\", "/"));
563+
//If this path is already a part of our list, don't add it
564+
if (!dccOptionPath.Contains(pathToAdd))
565+
{
566+
dccOptionPath.Add(pathToAdd);
567+
dccOptionName.Add("MAYA_LOCATION");
568+
}
551569
}
552570
instance.selectedDCCApp = instance.GetPreferredDCCApp();
553571
}
@@ -670,6 +688,14 @@ public static void AddDCCOption(string newOption, DCCType dcc){
670688
switch (dcc) {
671689
case DCCType.Maya:
672690
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+
}
673699
optionName = GetUniqueDCCOptionName("Maya " + version);
674700
break;
675701
case DCCType.Max:
@@ -719,7 +745,9 @@ static string AskMayaVersion(string exePath) {
719745
}
720746
else
721747
{
722-
return "unknown";
748+
//This probably means we tried to launch Maya to check the version but it was some sort of fake maya.
749+
//We'll just return null and throw an error for it.
750+
return null;
723751
}
724752
}
725753

0 commit comments

Comments
 (0)