Skip to content

Commit d7ee174

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-30583-hide-disabled-gameobjects-in-fbx
# Conflicts: # Assets/FbxExporters/Editor/UnitTests/ModelExporterTest.cs
2 parents 5f3981a + f19a850 commit d7ee174

File tree

8 files changed

+499
-149
lines changed

8 files changed

+499
-149
lines changed

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 77 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ namespace FbxExporters.EditorTools {
1010
[CustomEditor(typeof(ExportSettings))]
1111
public class ExportSettingsEditor : UnityEditor.Editor {
1212
Vector2 scrollPos = Vector2.zero;
13-
const float LabelWidth = 130;
13+
const float LabelWidth = 144;
1414
const float SelectableLabelMinWidth = 90;
1515
const float BrowseButtonWidth = 25;
16+
const float FieldOffset = 18;
17+
const float BrowseButtonOffset = 5;
1618

1719
public override void OnInspectorGUI() {
1820
ExportSettings exportSettings = (ExportSettings)target;
@@ -27,6 +29,8 @@ public override void OnInspectorGUI() {
2729
GUILayout.Label ("Version: " + version, EditorStyles.centeredGreyMiniLabel);
2830
EditorGUILayout.Space ();
2931
}
32+
EditorGUILayout.LabelField("Export Options", EditorStyles.boldLabel);
33+
EditorGUI.indentLevel++;
3034
GUILayout.BeginVertical();
3135
exportSettings.mayaCompatibleNames = EditorGUILayout.Toggle (
3236
new GUIContent ("Compatible Naming:",
@@ -45,47 +49,53 @@ public override void OnInspectorGUI() {
4549
exportSettings.centerObjects
4650
);
4751

48-
EditorGUILayout.Space();
49-
5052
GUILayout.BeginHorizontal();
51-
GUILayout.Label(new GUIContent("Export Format:", "Export the FBX file in the standard binary format." +
52-
" Select ASCII to export the FBX file in ASCII format."), GUILayout.Width(LabelWidth - 3));
53+
EditorGUILayout.LabelField(new GUIContent("Export Format:", "Export the FBX file in the standard binary format." +
54+
" Select ASCII to export the FBX file in ASCII format."), GUILayout.Width(LabelWidth - FieldOffset));
5355
exportSettings.ExportFormatSelection = EditorGUILayout.Popup(exportSettings.ExportFormatSelection, new string[]{"Binary", "ASCII"});
5456
GUILayout.EndHorizontal();
5557

56-
EditorGUILayout.Space();
57-
58-
GUILayout.BeginHorizontal ();
59-
GUILayout.Label (new GUIContent (
58+
GUILayout.BeginHorizontal();
59+
EditorGUILayout.LabelField(new GUIContent(
6060
"Export Path:",
61-
"Relative path for saving Model Prefabs."), GUILayout.Width(LabelWidth - 3));
61+
"Relative path for saving Model Prefabs."), GUILayout.Width(LabelWidth - FieldOffset));
6262

6363
var pathLabel = ExportSettings.GetRelativeSavePath();
6464
if (pathLabel == ".") { pathLabel = "(Assets root)"; }
6565
EditorGUILayout.SelectableLabel(pathLabel,
6666
EditorStyles.textField,
6767
GUILayout.MinWidth(SelectableLabelMinWidth),
6868
GUILayout.Height(EditorGUIUtility.singleLineHeight));
69+
GUILayout.EndHorizontal();
70+
GUILayout.BeginHorizontal();
71+
72+
GUILayout.Space(LabelWidth + BrowseButtonOffset);
6973

70-
if (GUILayout.Button (new GUIContent("...", "Browse to a new location for saving model prefabs"), EditorStyles.miniButton, GUILayout.Width (BrowseButtonWidth))) {
74+
if (GUILayout.Button(new GUIContent("...", "Browse to a new location for saving model prefabs"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth)))
75+
{
7176
string initialPath = ExportSettings.GetAbsoluteSavePath();
7277

7378
// if the directory doesn't exist, set it to the default save path
7479
// so we don't open somewhere unexpected
75-
if (!System.IO.Directory.Exists (initialPath)) {
80+
if (!System.IO.Directory.Exists(initialPath))
81+
{
7682
initialPath = Application.dataPath;
7783
}
7884

79-
string fullPath = EditorUtility.OpenFolderPanel (
85+
string fullPath = EditorUtility.OpenFolderPanel(
8086
"Select Model Prefabs Path", initialPath, null
8187
);
8288

8389
// Unless the user canceled, make sure they chose something in the Assets folder.
84-
if (!string.IsNullOrEmpty (fullPath)) {
90+
if (!string.IsNullOrEmpty(fullPath))
91+
{
8592
var relativePath = ExportSettings.ConvertToAssetRelativePath(fullPath);
86-
if (string.IsNullOrEmpty(relativePath)) {
87-
Debug.LogWarning ("Please select a location in the Assets folder");
88-
} else {
93+
if (string.IsNullOrEmpty(relativePath))
94+
{
95+
Debug.LogWarning("Please select a location in the Assets folder");
96+
}
97+
else
98+
{
8999
ExportSettings.SetRelativeSavePath(relativePath);
90100

91101
// Make sure focus is removed from the selectable label
@@ -95,18 +105,28 @@ public override void OnInspectorGUI() {
95105
}
96106
}
97107
}
98-
GUILayout.EndHorizontal ();
108+
GUILayout.EndHorizontal();
109+
110+
EditorGUILayout.Space();
111+
EditorGUILayout.Space();
112+
EditorGUI.indentLevel--;
113+
EditorGUILayout.LabelField("Integration", EditorStyles.boldLabel);
114+
EditorGUI.indentLevel++;
99115

100116
GUILayout.BeginHorizontal ();
101-
GUILayout.Label (new GUIContent (
117+
EditorGUILayout.LabelField(new GUIContent (
102118
"Integrations Path:",
103-
"Installation path for 3D application integrations."), GUILayout.Width(LabelWidth - 3));
119+
"Installation path for 3D application integrations."), GUILayout.Width(LabelWidth - FieldOffset));
104120

105121
var IntegrationsPathLabel = ExportSettings.GetIntegrationSavePath();
106122
EditorGUILayout.SelectableLabel(IntegrationsPathLabel,
107123
EditorStyles.textField,
108124
GUILayout.MinWidth(SelectableLabelMinWidth),
109125
GUILayout.Height(EditorGUIUtility.singleLineHeight));
126+
GUILayout.EndHorizontal();
127+
GUILayout.BeginHorizontal();
128+
129+
GUILayout.Space(LabelWidth + BrowseButtonOffset);
110130

111131
if (GUILayout.Button(new GUIContent("...", "Browse to a new installation path for 3D application integrations"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth)))
112132
{
@@ -129,17 +149,21 @@ public override void OnInspectorGUI() {
129149

130150
GUILayout.EndHorizontal();
131151

132-
EditorGUILayout.Space ();
133-
134152
GUILayout.BeginHorizontal ();
135-
GUILayout.Label (new GUIContent (
153+
EditorGUILayout.LabelField(new GUIContent (
136154
"3D Application:",
137-
"Select the 3D Application for which you would like to install the Unity integration."), GUILayout.Width(LabelWidth - 3));
155+
"Select the 3D Application for which you would like to install the Unity integration."), GUILayout.Width(LabelWidth - FieldOffset));
138156

139157
// dropdown to select Maya version to use
140158
var options = ExportSettings.GetDCCOptions();
141159

142160
exportSettings.selectedDCCApp = EditorGUILayout.Popup(exportSettings.selectedDCCApp, options);
161+
162+
GUILayout.EndHorizontal();
163+
GUILayout.BeginHorizontal();
164+
165+
GUILayout.Space(LabelWidth + BrowseButtonOffset);
166+
143167
if (GUILayout.Button(new GUIContent("...", "Browse to a 3D application in a non-default location"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth))) {
144168
var ext = "";
145169
switch (Application.platform) {
@@ -176,19 +200,28 @@ public override void OnInspectorGUI() {
176200

177201
EditorGUILayout.Space();
178202

203+
exportSettings.launchAfterInstallation = EditorGUILayout.Toggle(
204+
new GUIContent("Keep open:",
205+
"Keep the selected 3D application open after Unity integration install has completed."),
206+
exportSettings.launchAfterInstallation
207+
);
208+
209+
exportSettings.HideSendToUnityMenu = EditorGUILayout.Toggle(
210+
new GUIContent("Hide native menu:",
211+
"Replace Maya's native 'Send to Unity' menu with the Unity Integration's menu"),
212+
exportSettings.HideSendToUnityMenu
213+
);
214+
215+
EditorGUILayout.Space();
216+
217+
179218
var installIntegrationContent = new GUIContent(
180219
"Install Unity Integration",
181220
"Install and configure the Unity integration for the selected 3D application so that you can import and export directly with this project.");
182221
if (GUILayout.Button (installIntegrationContent)) {
183222
FbxExporters.Editor.IntegrationsUI.InstallDCCIntegration ();
184223
}
185224

186-
exportSettings.launchAfterInstallation = EditorGUILayout.Toggle(
187-
new GUIContent("Keep 3D Application opened:",
188-
"Keep the selected 3D application open after Unity integration install has completed."),
189-
exportSettings.launchAfterInstallation
190-
);
191-
192225
GUILayout.FlexibleSpace ();
193226
GUILayout.EndScrollView ();
194227
GUILayout.EndVertical();
@@ -300,6 +333,7 @@ public static string[] DCCVendorLocations {
300333
public bool mayaCompatibleNames;
301334
public bool centerObjects;
302335
public bool launchAfterInstallation;
336+
public bool HideSendToUnityMenu;
303337
public int ExportFormatSelection;
304338

305339
public string IntegrationSavePath;
@@ -331,6 +365,7 @@ protected override void LoadDefaults()
331365
mayaCompatibleNames = true;
332366
centerObjects = true;
333367
launchAfterInstallation = true;
368+
HideSendToUnityMenu = true;
334369
ExportFormatSelection = 0;
335370
convertToModelSavePath = kDefaultSavePath;
336371
IntegrationSavePath = DefaultIntegrationSavePath;
@@ -601,15 +636,15 @@ public static GUIContent[] GetDCCOptions(){
601636
FindDCCInstalls ();
602637
}
603638

639+
// store the selected app
640+
var prevSelection = instance.dccOptionPaths[instance.selectedDCCApp];
641+
604642
// remove options that no longer exist
605643
List<string> pathsToDelete = new List<string>();
606644
List<string> namesToDelete = new List<string>();
607645
for(int i = 0; i < instance.dccOptionPaths.Count; i++) {
608646
var dccPath = instance.dccOptionPaths [i];
609647
if (!File.Exists (dccPath)) {
610-
if (i == instance.selectedDCCApp) {
611-
instance.selectedDCCApp = instance.GetPreferredDCCApp();
612-
}
613648
namesToDelete.Add (instance.dccOptionNames [i]);
614649
pathsToDelete.Add (dccPath);
615650
}
@@ -621,6 +656,13 @@ public static GUIContent[] GetDCCOptions(){
621656
instance.dccOptionNames.Remove (str);
622657
}
623658

659+
// set the selected DCC app to the previous selection
660+
instance.selectedDCCApp = instance.dccOptionPaths.IndexOf (prevSelection);
661+
if (instance.selectedDCCApp < 0) {
662+
// find preferred app if previous selection no longer exists
663+
instance.selectedDCCApp = instance.GetPreferredDCCApp ();
664+
}
665+
624666
if (instance.dccOptionPaths.Count <= 0) {
625667
instance.selectedDCCApp = 0;
626668
return new GUIContent[]{
@@ -635,7 +677,6 @@ public static GUIContent[] GetDCCOptions(){
635677
instance.dccOptionPaths[i]
636678
);
637679
}
638-
639680
return optionArray;
640681
}
641682

@@ -762,7 +803,8 @@ public static void SetRelativeSavePath(string newPath) {
762803
public static string GetIntegrationSavePath()
763804
{
764805
//If the save path gets messed up and ends up not being valid, just use the project folder as the default
765-
if (string.IsNullOrEmpty(instance.IntegrationSavePath.Trim()) || !Directory.Exists(instance.IntegrationSavePath))
806+
if (string.IsNullOrEmpty(instance.IntegrationSavePath) ||
807+
!Directory.Exists(instance.IntegrationSavePath))
766808
{
767809
//The project folder, above the asset folder
768810
instance.IntegrationSavePath = DefaultIntegrationSavePath;

0 commit comments

Comments
 (0)