Skip to content

Commit 120595b

Browse files
author
AJubrey
committed
Merge branch 'master' into Uni-31847_prompt_user_for_integration_path
# Conflicts: # Assets/FbxExporters/Editor/FbxExportSettings.cs
2 parents b1031f5 + 7f174c2 commit 120595b

File tree

11 files changed

+583
-147
lines changed

11 files changed

+583
-147
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ public static GameObject Convert (
180180
prefabFileName, fbxFullPath));
181181
}
182182

183+
toConvert.name = Path.GetFileNameWithoutExtension (fbxFullPath);
183184
return toConvert;
184185
}
185186

Assets/FbxExporters/Editor/FbxExportSettings.cs

Lines changed: 70 additions & 32 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,19 +105,29 @@ public override void OnInspectorGUI() {
95105
}
96106
}
97107
}
98-
GUILayout.EndHorizontal ();
108+
GUILayout.EndHorizontal();
99109

100-
EditorGUILayout.Space ();
110+
EditorGUILayout.Space();
111+
EditorGUILayout.Space();
112+
EditorGUI.indentLevel--;
113+
EditorGUILayout.LabelField("Integration", EditorStyles.boldLabel);
114+
EditorGUI.indentLevel++;
101115

102116
GUILayout.BeginHorizontal ();
103-
GUILayout.Label (new GUIContent (
117+
EditorGUILayout.LabelField(new GUIContent (
104118
"3D Application:",
105-
"Select the 3D Application for which you would like to install the Unity integration."), GUILayout.Width(LabelWidth - 3));
119+
"Select the 3D Application for which you would like to install the Unity integration."), GUILayout.Width(LabelWidth - FieldOffset));
106120

107121
// dropdown to select Maya version to use
108122
var options = ExportSettings.GetDCCOptions();
109123

110124
exportSettings.selectedDCCApp = EditorGUILayout.Popup(exportSettings.selectedDCCApp, options);
125+
126+
GUILayout.EndHorizontal();
127+
GUILayout.BeginHorizontal();
128+
129+
GUILayout.Space(LabelWidth + BrowseButtonOffset);
130+
111131
if (GUILayout.Button(new GUIContent("...", "Browse to a 3D application in a non-default location"), EditorStyles.miniButton, GUILayout.Width(BrowseButtonWidth))) {
112132
var ext = "";
113133
switch (Application.platform) {
@@ -144,19 +164,28 @@ public override void OnInspectorGUI() {
144164

145165
EditorGUILayout.Space();
146166

167+
exportSettings.launchAfterInstallation = EditorGUILayout.Toggle(
168+
new GUIContent("Keep open:",
169+
"Keep the selected 3D application open after Unity integration install has completed."),
170+
exportSettings.launchAfterInstallation
171+
);
172+
173+
exportSettings.HideSendToUnityMenu = EditorGUILayout.Toggle(
174+
new GUIContent("Hide native menu:",
175+
"Replace Maya's native 'Send to Unity' menu with the Unity Integration's menu"),
176+
exportSettings.HideSendToUnityMenu
177+
);
178+
179+
EditorGUILayout.Space();
180+
181+
147182
var installIntegrationContent = new GUIContent(
148183
"Install Unity Integration",
149184
"Install and configure the Unity integration for the selected 3D application so that you can import and export directly with this project.");
150185
if (GUILayout.Button (installIntegrationContent)) {
151186
FbxExporters.Editor.IntegrationsUI.InstallDCCIntegration ();
152187
}
153188

154-
exportSettings.launchAfterInstallation = EditorGUILayout.Toggle(
155-
new GUIContent("Keep 3D Application opened:",
156-
"Keep the selected 3D application open after Unity integration install has completed."),
157-
exportSettings.launchAfterInstallation
158-
);
159-
160189
GUILayout.FlexibleSpace ();
161190
GUILayout.EndScrollView ();
162191
GUILayout.EndVertical();
@@ -268,6 +297,7 @@ public static string[] DCCVendorLocations {
268297
public bool mayaCompatibleNames;
269298
public bool centerObjects;
270299
public bool launchAfterInstallation;
300+
public bool HideSendToUnityMenu;
271301
public int ExportFormatSelection;
272302

273303
public string IntegrationSavePath;
@@ -299,6 +329,7 @@ protected override void LoadDefaults()
299329
mayaCompatibleNames = true;
300330
centerObjects = true;
301331
launchAfterInstallation = true;
332+
HideSendToUnityMenu = true;
302333
ExportFormatSelection = 0;
303334
convertToModelSavePath = kDefaultSavePath;
304335
IntegrationSavePath = DefaultIntegrationSavePath;
@@ -569,15 +600,15 @@ public static GUIContent[] GetDCCOptions(){
569600
FindDCCInstalls ();
570601
}
571602

603+
// store the selected app
604+
var prevSelection = instance.dccOptionPaths[instance.selectedDCCApp];
605+
572606
// remove options that no longer exist
573607
List<string> pathsToDelete = new List<string>();
574608
List<string> namesToDelete = new List<string>();
575609
for(int i = 0; i < instance.dccOptionPaths.Count; i++) {
576610
var dccPath = instance.dccOptionPaths [i];
577611
if (!File.Exists (dccPath)) {
578-
if (i == instance.selectedDCCApp) {
579-
instance.selectedDCCApp = instance.GetPreferredDCCApp();
580-
}
581612
namesToDelete.Add (instance.dccOptionNames [i]);
582613
pathsToDelete.Add (dccPath);
583614
}
@@ -589,6 +620,13 @@ public static GUIContent[] GetDCCOptions(){
589620
instance.dccOptionNames.Remove (str);
590621
}
591622

623+
// set the selected DCC app to the previous selection
624+
instance.selectedDCCApp = instance.dccOptionPaths.IndexOf (prevSelection);
625+
if (instance.selectedDCCApp < 0) {
626+
// find preferred app if previous selection no longer exists
627+
instance.selectedDCCApp = instance.GetPreferredDCCApp ();
628+
}
629+
592630
if (instance.dccOptionPaths.Count <= 0) {
593631
instance.selectedDCCApp = 0;
594632
return new GUIContent[]{
@@ -603,7 +641,6 @@ public static GUIContent[] GetDCCOptions(){
603641
instance.dccOptionPaths[i]
604642
);
605643
}
606-
607644
return optionArray;
608645
}
609646

@@ -730,7 +767,8 @@ public static void SetRelativeSavePath(string newPath) {
730767
public static string GetIntegrationSavePath()
731768
{
732769
//If the save path gets messed up and ends up not being valid, just use the project folder as the default
733-
if (string.IsNullOrEmpty(instance.IntegrationSavePath.Trim()) || !Directory.Exists(instance.IntegrationSavePath))
770+
if (string.IsNullOrEmpty(instance.IntegrationSavePath) ||
771+
!Directory.Exists(instance.IntegrationSavePath))
734772
{
735773
//The project folder, above the asset folder
736774
instance.IntegrationSavePath = DefaultIntegrationSavePath;

0 commit comments

Comments
 (0)