Skip to content

Commit 8890356

Browse files
committed
refactor AddDCCOption to add both max/maya as options
rename maya specific functions
1 parent ce688f0 commit 8890356

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public override void OnInspectorGUI() {
146146
return;
147147
}
148148
}
149-
ExportSettings.AddDCCOption (dccPath);
149+
ExportSettings.AddDCCOption (dccPath, ExportSettings.DCCType.Maya);
150150
Repaint ();
151151
} else {
152152
exportSettings.selectedDCCApp = oldValue;
@@ -243,7 +243,7 @@ protected override void LoadDefaults()
243243
}
244244

245245
/// <summary>
246-
/// Increments the name if there is a duplicate in MayaAppOptions dictionary.
246+
/// Increments the name if there is a duplicate in dccAppOptions.
247247
/// </summary>
248248
/// <returns>The unique name.</returns>
249249
/// <param name="name">Name.</param>
@@ -294,7 +294,7 @@ private static void FindMaxInstalls(){
294294
}
295295
string version = product.Substring ("3ds max ".Length);
296296
maxOptionPath.Add (string.Format("{0}/{1}", productDir.FullName.Replace ("\\", "/"), "3dsmax.exe"));
297-
maxOptionName.Add (GetUniqueName("3Ds Max " + version));
297+
maxOptionName.Add (GetUniqueName("3ds Max " + version));
298298
}
299299
}
300300

@@ -376,8 +376,8 @@ public static GUIContent[] GetDCCOptions(){
376376
// remove options that no longer exist
377377
List<int> toDelete = new List<int>();
378378
for(int i = 0; i < instance.dccOptionPaths.Count; i++) {
379-
var mayaPath = instance.dccOptionPaths [i];
380-
if (!File.Exists (mayaPath)) {
379+
var dccPath = instance.dccOptionPaths [i];
380+
if (!File.Exists (dccPath)) {
381381
if (i == instance.selectedDCCApp) {
382382
instance.selectedDCCApp = 0;
383383
}
@@ -401,22 +401,36 @@ public static GUIContent[] GetDCCOptions(){
401401
return optionArray;
402402
}
403403

404-
public static void AddDCCOption(string newOption){
405-
// on OSX we get a path ending in .app, which is not quite the exe
406-
#if UNITY_EDITOR_OSX
407-
newOption = GetMayaExePath(newOption);
408-
#endif
404+
public enum DCCType { Maya, Max };
405+
406+
public static void AddDCCOption(string newOption, DCCType dcc){
407+
if (Application.platform == RuntimePlatform.OSXEditor && dcc == DCCType.Maya) {
408+
// on OSX we get a path ending in .app, which is not quite the exe
409+
newOption = GetMayaExePath(newOption);
410+
}
409411

410-
var mayaOptionPaths = instance.dccOptionPaths;
411-
if (mayaOptionPaths.Contains(newOption)) {
412-
instance.selectedDCCApp = mayaOptionPaths.IndexOf (newOption);
412+
var dccOptionPaths = instance.dccOptionPaths;
413+
if (dccOptionPaths.Contains(newOption)) {
414+
instance.selectedDCCApp = dccOptionPaths.IndexOf (newOption);
413415
return;
414416
}
415-
// get the version
416-
var version = AskMayaVersion(newOption);
417-
instance.dccOptionNames.Add (GetUniqueName("Maya "+version));
418-
mayaOptionPaths.Add (newOption);
419-
instance.selectedDCCApp = mayaOptionPaths.Count - 1;
417+
418+
string optionName = "";
419+
switch (dcc) {
420+
case DCCType.Maya:
421+
var version = AskMayaVersion(newOption);
422+
optionName = GetUniqueName ("Maya " + version);
423+
break;
424+
case DCCType.Max:
425+
optionName = GetMaxOptionName (newOption);
426+
break;
427+
default:
428+
throw new System.NotImplementedException();
429+
}
430+
431+
instance.dccOptionNames.Add (optionName);
432+
dccOptionPaths.Add (newOption);
433+
instance.selectedDCCApp = dccOptionPaths.Count - 1;
420434
}
421435

422436
/// <summary>
@@ -442,7 +456,16 @@ static string AskMayaVersion(string exePath) {
442456
return resultString.Substring(0, commaIndex).Substring("Maya ".Length);
443457
}
444458

445-
public static string GetSelectedMayaPath()
459+
/// <summary>
460+
/// Gets the unique label for a new 3DsMax dropdown option.
461+
/// </summary>
462+
/// <returns>The 3DsMax dropdown option label.</returns>
463+
/// <param name="exePath">Exe path.</param>
464+
public static string GetMaxOptionName(string exePath){
465+
return GetUniqueName (Path.GetFileName(Path.GetDirectoryName (exePath)));
466+
}
467+
468+
public static string GetSelectedDCCPath()
446469
{
447470
return instance.dccOptionPaths [instance.selectedDCCApp];
448471
}

Assets/FbxExporters/Editor/InstallIntegration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ class IntegrationsUI
452452
/// The path of the Maya executable.
453453
/// </summary>
454454
public static string GetMayaExe () {
455-
return FbxExporters.EditorTools.ExportSettings.GetSelectedMayaPath ();
455+
return FbxExporters.EditorTools.ExportSettings.GetSelectedDCCPath ();
456456
}
457457

458458
/// <summary>

0 commit comments

Comments
 (0)