Skip to content

Commit 71c8707

Browse files
committed
avoid changing dcc app selection before list is modified
- no point changing the index selected before the items are actually removed from the list because the indices are still changing. - try to set the value to the previous selection if it is still in the list, otherwise get the preferred app
1 parent cd0309f commit 71c8707

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -601,15 +601,15 @@ public static GUIContent[] GetDCCOptions(){
601601
FindDCCInstalls ();
602602
}
603603

604+
// store the selected app
605+
var currentSelection = instance.dccOptionPaths[instance.selectedDCCApp];
606+
604607
// remove options that no longer exist
605608
List<string> pathsToDelete = new List<string>();
606609
List<string> namesToDelete = new List<string>();
607610
for(int i = 0; i < instance.dccOptionPaths.Count; i++) {
608611
var dccPath = instance.dccOptionPaths [i];
609612
if (!File.Exists (dccPath)) {
610-
if (i == instance.selectedDCCApp) {
611-
instance.selectedDCCApp = instance.GetPreferredDCCApp();
612-
}
613613
namesToDelete.Add (instance.dccOptionNames [i]);
614614
pathsToDelete.Add (dccPath);
615615
}
@@ -621,6 +621,13 @@ public static GUIContent[] GetDCCOptions(){
621621
instance.dccOptionNames.Remove (str);
622622
}
623623

624+
// set the selected DCC app to the previous selection
625+
instance.selectedDCCApp = instance.dccOptionPaths.IndexOf (currentSelection);
626+
if (instance.selectedDCCApp < 0) {
627+
// find preferred app if previous selection no longer exists
628+
instance.selectedDCCApp = instance.GetPreferredDCCApp ();
629+
}
630+
624631
if (instance.dccOptionPaths.Count <= 0) {
625632
instance.selectedDCCApp = 0;
626633
return new GUIContent[]{
@@ -635,7 +642,6 @@ public static GUIContent[] GetDCCOptions(){
635642
instance.dccOptionPaths[i]
636643
);
637644
}
638-
639645
return optionArray;
640646
}
641647

0 commit comments

Comments
 (0)