Skip to content

Commit 46b8473

Browse files
author
AJubrey
committed
[CHANGED] made the environment variable only accessible through a get accessor instead of a function
[CHANGED] we now weed out bad paths if provided by the user [CHANGED] a few minor efficiency / coding standard things [CHANGED] we only attempt to search valid paths [FIXED] bug where the selection popup for selected DCC could be blank, this shouldn't happen anymore
1 parent 0568d7e commit 46b8473

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public override void OnInspectorGUI() {
111111
throw new System.NotImplementedException ();
112112
}
113113

114-
string dccPath = EditorUtility.OpenFilePanel ("Select Digital Content Creation Application", ExportSettings.DCCVendorLocations()[0], ext);
114+
string dccPath = EditorUtility.OpenFilePanel ("Select Digital Content Creation Application", ExportSettings.DCCVendorLocations[0], ext);
115115

116116
// check that the path is valid and references the maya executable
117117
if (!string.IsNullOrEmpty (dccPath)) {
@@ -229,28 +229,36 @@ public class ExportSettings : ScriptableSingleton<ExportSettings>
229229
/// The paths where all the different versions of Maya are installed
230230
/// by default. Depends on the platform.
231231
/// </summary>
232-
public static string[] DCCVendorLocations() {
233-
234-
if (Environment.GetEnvironmentVariable("UNITY_FBX_3DAPP_VENDOR_LOCATIONS") != null)
235-
{
236-
string[] locations = Environment.GetEnvironmentVariable("UNITY_FBX_3DAPP_VENDOR_LOCATIONS").Split(';');
237-
for (int i = 0; i < locations.Length; i++)
232+
public static string[] DCCVendorLocations {
233+
get{
234+
var environmentVariable = Environment.GetEnvironmentVariable("UNITY_FBX_3DAPP_VENDOR_LOCATIONS");
235+
if (environmentVariable != null)
238236
{
239-
if (Directory.Exists(locations[i]))
237+
string[] locations = environmentVariable.Split(';');
238+
List<string> locationsList = new List<string>();
239+
for (int i = 0; i < locations.Length; i++)
240+
{
241+
if (Directory.Exists(locations[i]))
242+
{
243+
locationsList.Add(locations[i]);
244+
}
245+
}
246+
if (locationsList.Count > 0)
240247
{
241-
return locations;
248+
return locationsList.ToArray();
242249
}
243250
}
244-
}
245251

246-
switch (Application.platform) {
247-
case RuntimePlatform.WindowsEditor:
248-
return new string[]{ "C:/Program Files/Autodesk", "D:/Program Files/Autodesk" };
249-
case RuntimePlatform.OSXEditor:
250-
return new string[]{ "/Applications/Autodesk" };
251-
default:
252-
throw new NotImplementedException ();
253-
}
252+
switch (Application.platform)
253+
{
254+
case RuntimePlatform.WindowsEditor:
255+
return new string[] { "C:/Program Files/Autodesk", "D:/Program Files/Autodesk" };
256+
case RuntimePlatform.OSXEditor:
257+
return new string[] { "/Applications/Autodesk" };
258+
default:
259+
throw new NotImplementedException();
260+
}
261+
}
254262
}
255263

256264
// Note: default values are set in LoadDefaults().
@@ -455,16 +463,16 @@ private static void FindDCCInstalls() {
455463
var dccOptionName = instance.dccOptionNames;
456464
var dccOptionPath = instance.dccOptionPaths;
457465

458-
for (int i = 0; i < DCCVendorLocations().Length; i++)
466+
for (int i = 0; i < DCCVendorLocations.Length; i++)
459467
{
460-
if (!Directory.Exists(DCCVendorLocations()[0]))
468+
if (!Directory.Exists(DCCVendorLocations[i]))
461469
{
462470
// no autodesk products installed
463471
continue;
464472
}
465473
// List that directory and find the right version:
466474
// either the newest version, or the exact version we wanted.
467-
var adskRoot = new System.IO.DirectoryInfo(DCCVendorLocations()[i]);
475+
var adskRoot = new System.IO.DirectoryInfo(DCCVendorLocations[i]);
468476
foreach (var productDir in adskRoot.GetDirectories())
469477
{
470478
var product = productDir.Name;
@@ -561,6 +569,7 @@ public static GUIContent[] GetDCCOptions(){
561569
}
562570

563571
if (instance.dccOptionPaths.Count <= 0) {
572+
instance.selectedDCCApp = 0;
564573
return new GUIContent[]{
565574
new GUIContent("<No 3D Application found>")
566575
};

0 commit comments

Comments
 (0)