Skip to content

Commit 515d0ca

Browse files
committed
browse for both 3dsmax and maya
check if user selected maya or 3dsmax, and if not then see if either is contained in the same folder
1 parent 8890356 commit 515d0ca

File tree

1 file changed

+69
-34
lines changed

1 file changed

+69
-34
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 69 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -114,39 +114,35 @@ public override void OnInspectorGUI() {
114114
int oldValue = exportSettings.selectedDCCApp;
115115
exportSettings.selectedDCCApp = EditorGUILayout.Popup(exportSettings.selectedDCCApp, options);
116116
if (exportSettings.selectedDCCApp == options.Length - 1) {
117-
var ext = "exe";
118-
#if UNITY_EDITOR_OSX
119-
ext = "app";
120-
#endif
117+
var ext = "";
118+
switch (Application.platform) {
119+
case RuntimePlatform.WindowsEditor:
120+
ext = "exe";
121+
break;
122+
case RuntimePlatform.OSXEditor:
123+
ext = "app";
124+
break;
125+
default:
126+
throw new System.NotImplementedException ();
127+
}
128+
121129
string dccPath = EditorUtility.OpenFilePanel ("Select DCC Application", ExportSettings.kDefaultAdskRoot, ext);
122130

123131
// check that the path is valid and references the maya executable
124132
if (!string.IsNullOrEmpty (dccPath)) {
125-
if (!Path.GetFileNameWithoutExtension (dccPath).ToLower ().Equals ("maya")) {
126-
// clicked on the wrong application, try to see if we can still find
127-
// maya in this directory.
128-
var mayaDir = new DirectoryInfo(Path.GetDirectoryName(dccPath));
129-
#if UNITY_EDITOR_OSX
130-
var files = mayaDir.GetDirectories("*." + ext);
131-
#else
132-
var files = mayaDir.GetFiles ("*." + ext);
133-
#endif
134-
bool foundMaya = false;
135-
foreach (var file in files) {
136-
var filename = Path.GetFileNameWithoutExtension (file.Name).ToLower ();
137-
if (filename.Equals ("maya")) {
138-
dccPath = file.FullName.Replace("\\","/");
139-
foundMaya = true;
140-
break;
141-
}
142-
}
143-
if (!foundMaya) {
144-
Debug.LogError (string.Format("Could not find Maya at: \"{0}\"", mayaDir.FullName));
145-
exportSettings.selectedDCCApp = oldValue;
146-
return;
147-
}
133+
bool foundMax = false;
134+
var foundDCCPath = TryFindDCC (dccPath, ext, ExportSettings.DCCType.Maya);
135+
if (foundDCCPath == null && Application.platform == RuntimePlatform.WindowsEditor) {
136+
foundDCCPath = TryFindDCC (dccPath, ext, ExportSettings.DCCType.Max);
137+
foundMax = true;
138+
}
139+
if (foundDCCPath == null) {
140+
Debug.LogError (string.Format ("Could not find supported DCC application at: \"{0}\"", Path.GetDirectoryName (dccPath)));
141+
exportSettings.selectedDCCApp = oldValue;
142+
} else {
143+
dccPath = foundDCCPath;
144+
ExportSettings.AddDCCOption (dccPath, foundMax? ExportSettings.DCCType.Max : ExportSettings.DCCType.Maya);
148145
}
149-
ExportSettings.AddDCCOption (dccPath, ExportSettings.DCCType.Maya);
150146
Repaint ();
151147
} else {
152148
exportSettings.selectedDCCApp = oldValue;
@@ -156,13 +152,9 @@ public override void OnInspectorGUI() {
156152

157153
var installIntegrationContent = new GUIContent(
158154
"Install Unity Integration",
159-
"Install and configure the Unity integration for Maya so that you can import and export directly to this project.");
155+
"Install and configure the Unity integration for the selected DCC so that you can import and export directly to this project.");
160156
if (GUILayout.Button (installIntegrationContent)) {
161-
FbxExporters.Editor.IntegrationsUI.InstallMayaIntegration ();
162-
}
163-
164-
if (GUILayout.Button ("Install 3DS Max Integration")) {
165-
FbxExporters.Editor.IntegrationsUI.InstallMaxIntegration ();
157+
//FbxExporters.Editor.IntegrationsUI.InstallMayaIntegration ();
166158
}
167159

168160
GUILayout.FlexibleSpace ();
@@ -174,6 +166,49 @@ public override void OnInspectorGUI() {
174166
}
175167
}
176168

169+
private static string TryFindDCC(string dccPath, string ext, ExportSettings.DCCType dccType){
170+
string dccName = "";
171+
switch (dccType) {
172+
case ExportSettings.DCCType.Maya:
173+
dccName = "maya";
174+
break;
175+
case ExportSettings.DCCType.Max:
176+
dccName = "3dsmax";
177+
break;
178+
default:
179+
throw new System.NotImplementedException ();
180+
}
181+
182+
if (Path.GetFileNameWithoutExtension (dccPath).ToLower ().Equals (dccName)) {
183+
return dccPath;
184+
}
185+
186+
// clicked on the wrong application, try to see if we can still find
187+
// a dcc in this directory.
188+
var dccDir = new DirectoryInfo(Path.GetDirectoryName(dccPath));
189+
FileSystemInfo[] files = {};
190+
switch(Application.platform){
191+
case RuntimePlatform.OSXEditor:
192+
files = dccDir.GetDirectories ("*." + ext);
193+
break;
194+
case RuntimePlatform.WindowsEditor:
195+
files = dccDir.GetFiles ("*." + ext);
196+
break;
197+
default:
198+
throw new System.NotImplementedException();
199+
}
200+
201+
string newDccPath = null;
202+
foreach (var file in files) {
203+
var filename = Path.GetFileNameWithoutExtension (file.Name).ToLower ();
204+
if (filename.Equals (dccName)) {
205+
newDccPath = file.FullName.Replace("\\","/");
206+
break;
207+
}
208+
}
209+
return newDccPath;
210+
}
211+
177212
}
178213

179214
[FilePath("ProjectSettings/FbxExportSettings.asset",FilePathAttribute.Location.ProjectFolder)]

0 commit comments

Comments
 (0)