Skip to content

Commit 1b9fe89

Browse files
committed
add dropdown menu to select maya version to install to
1 parent 0105eee commit 1b9fe89

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,32 @@ public override void OnInspectorGUI() {
100100
GUILayout.EndHorizontal ();
101101

102102
EditorGUILayout.Space ();
103+
104+
GUILayout.BeginHorizontal ();
105+
GUILayout.Label (new GUIContent (
106+
"Maya Application:",
107+
"Maya location to install plugins to."));
108+
109+
// dropdown to select Maya version to use
110+
var options = ExportSettings.GetMayaOptions();
111+
// make sure we never initially have browse selected
112+
if (exportSettings.selectedMayaApp == options.Length - 1) {
113+
exportSettings.selectedMayaApp = 0;
114+
}
115+
int result = EditorGUILayout.Popup(exportSettings.selectedMayaApp, options);
116+
if (result == options.Length - 1) {
117+
string mayaPath = EditorUtility.OpenFilePanel ("Select Maya Application", ExportSettings.kDefaultAdskRoot, "exe");
118+
if (!string.IsNullOrEmpty (mayaPath)) {
119+
ExportSettings.AddMayaOption (mayaPath);
120+
Repaint ();
121+
}
122+
} else {
123+
exportSettings.selectedMayaApp = result;
124+
}
125+
126+
127+
GUILayout.EndHorizontal ();
128+
103129
if (GUILayout.Button ("Install Maya Integration")) {
104130
FbxExporters.Editor.IntegrationsUI.InstallMayaIntegration ();
105131
}
@@ -120,11 +146,27 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
120146
{
121147
public const string kDefaultSavePath = ".";
122148

149+
/// <summary>
150+
/// The path where all the different versions of Maya are installed
151+
/// by default. Depends on the platform.
152+
/// </summary>
153+
public const string kDefaultAdskRoot =
154+
#if UNITY_EDITOR_OSX
155+
"/Applications/Autodesk"
156+
#elif UNITY_EDITOR_LINUX
157+
"/usr/autodesk"
158+
#else // WINDOWS
159+
"C:/Program Files/Autodesk"
160+
#endif
161+
;
162+
123163
// Note: default values are set in LoadDefaults().
124164
public bool weldVertices;
125165
public bool mayaCompatibleNames;
126166
public bool centerObjects;
127167

168+
public int selectedMayaApp = 0;
169+
128170
[SerializeField]
129171
public UnityEngine.Object turntableScene;
130172

@@ -141,13 +183,52 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
141183
[SerializeField]
142184
string convertToModelSavePath;
143185

186+
//[SerializeField]
187+
// List of paths in order that they appear in the option list
188+
private System.Collections.Generic.List<string> mayaOptionPaths;
189+
//[SerializeField]
190+
// Dictionary of path -> display name
191+
private System.Collections.Generic.Dictionary<string, string> mayaAppOptions;
192+
144193
protected override void LoadDefaults()
145194
{
146195
weldVertices = true;
147196
mayaCompatibleNames = true;
148197
centerObjects = true;
149198
convertToModelSavePath = kDefaultSavePath;
150199
turntableScene = null;
200+
mayaAppOptions = null;
201+
}
202+
203+
public static GUIContent[] GetMayaOptions(){
204+
if (instance.mayaAppOptions == null) {
205+
instance.mayaAppOptions = new System.Collections.Generic.Dictionary<string, string> ();
206+
instance.mayaAppOptions.Add ("c:/", "Maya2017");
207+
instance.mayaAppOptions.Add ("d:/", "Maya2018");
208+
209+
instance.mayaOptionPaths = new System.Collections.Generic.List<string> (){ "c:/", "d:/" };
210+
}
211+
GUIContent[] optionArray = new GUIContent[instance.mayaAppOptions.Count+1];
212+
for(int i = 0; i < instance.mayaOptionPaths.Count; i++){
213+
optionArray [i] = new GUIContent(
214+
instance.mayaAppOptions [instance.mayaOptionPaths [i]],
215+
instance.mayaOptionPaths[i]
216+
);
217+
}
218+
optionArray [optionArray.Length - 1] = new GUIContent("Browse");
219+
220+
return optionArray;
221+
}
222+
223+
public static void AddMayaOption(string newOption){
224+
var mayaAppOptions = instance.mayaAppOptions;
225+
if (mayaAppOptions.ContainsKey (newOption)) {
226+
instance.selectedMayaApp = instance.mayaOptionPaths.IndexOf (newOption);
227+
return;
228+
}
229+
mayaAppOptions.Add (newOption, "Custom Maya Location");
230+
instance.mayaOptionPaths.Add (newOption);
231+
instance.selectedMayaApp = instance.mayaOptionPaths.Count - 1;
151232
}
152233

153234
public static string GetTurnTableSceneName(){

0 commit comments

Comments
 (0)