Skip to content

Commit d7dd1e0

Browse files
authored
Merge pull request #416 from Unity-Technologies/UT-587-one-click-convert
Uni-46903 add checkbox to not show convert options on next convert
2 parents e66128c + 5a3a9eb commit d7dd1e0

File tree

4 files changed

+41
-3
lines changed

4 files changed

+41
-3
lines changed

Packages/com.unity.formats.fbx/Editor/Scripts/ConvertToModel.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using UnityEngine.Formats.Fbx.Exporter;
66

77
namespace UnityEditor.Formats.Fbx.Exporter
8-
{
8+
{
99
public static class ConvertToModel
1010
{
1111
const string GameObjectMenuItemName = "GameObject/Convert To Linked Prefab Instance...";
@@ -83,8 +83,24 @@ public static GameObject[] CreateInstantiatedModelPrefab (
8383
GameObject [] unityGameObjectsToConvert)
8484
{
8585
var toExport = ModelExporter.RemoveRedundantObjects (unityGameObjectsToConvert);
86-
ConvertToPrefabEditorWindow.Init (toExport);
87-
return toExport.ToArray();
86+
87+
if (ExportSettings.instance.showConvertToPrefabDialog)
88+
{
89+
ConvertToPrefabEditorWindow.Init(toExport);
90+
return toExport.ToArray();
91+
}
92+
93+
var converted = new List<GameObject>();
94+
var exportOptions = ExportSettings.instance.convertToPrefabSettings.info;
95+
foreach (var go in toExport)
96+
{
97+
var convertedGO = Convert(go, exportOptions: exportOptions);
98+
if(convertedGO != null)
99+
{
100+
converted.Add(convertedGO);
101+
}
102+
}
103+
return converted.ToArray();
88104
}
89105

90106
/// <summary>

Packages/com.unity.formats.fbx/Editor/Scripts/ConvertToPrefabEditorWindow.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,5 +266,14 @@ protected override void CreateCustomUI()
266266
}
267267
GUILayout.EndHorizontal();
268268
}
269+
270+
protected override void DontShowDialogUI()
271+
{
272+
EditorGUI.indentLevel--;
273+
ExportSettings.instance.showConvertToPrefabDialog = !EditorGUILayout.Toggle(
274+
new GUIContent("Don't ask me again", "Don't ask me again, use the last used paths and options instead"),
275+
!ExportSettings.instance.showConvertToPrefabDialog
276+
);
277+
}
269278
}
270279
}

Packages/com.unity.formats.fbx/Editor/Scripts/ExportModelEditorWindow.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ protected bool TransferAnimationDestIsValid(Transform newValue){
239239
return true;
240240
}
241241

242+
/// <summary>
243+
/// Add UI to turn the dialog off next time the user exports
244+
/// </summary>
245+
protected virtual void DontShowDialogUI() { }
246+
242247
// -------------------------------------------------------------------------------------
243248

244249
protected void OnGUI ()
@@ -351,6 +356,7 @@ protected void OnGUI ()
351356
GUILayout.FlexibleSpace ();
352357

353358
GUILayout.BeginHorizontal ();
359+
DontShowDialogUI();
354360
GUILayout.FlexibleSpace ();
355361
if (GUILayout.Button ("Cancel", GUILayout.Width(ExportButtonWidth))) {
356362
this.Close ();

Packages/com.unity.formats.fbx/Editor/Scripts/FbxExportSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ public override void OnInspectorGUI() {
3737
"Automatically updates prefabs with new fbx data that was imported."),
3838
exportSettings.autoUpdaterEnabled
3939
);
40+
41+
exportSettings.showConvertToPrefabDialog = EditorGUILayout.Toggle(
42+
new GUIContent("Show Convert UI:", "Enable Convert dialog when converting to a Linked Prefab"),
43+
exportSettings.showConvertToPrefabDialog
44+
);
4045
EditorGUILayout.Space();
4146
EditorGUILayout.Space();
4247
EditorGUI.indentLevel--;
@@ -366,6 +371,7 @@ public static string[] DCCVendorLocations
366371
public bool launchAfterInstallation = true;
367372
public bool HideSendToUnityMenu = true;
368373
public bool BakeAnimation = true;
374+
public bool showConvertToPrefabDialog = true;
369375

370376
public string IntegrationSavePath;
371377

@@ -419,6 +425,7 @@ public static string[] DCCVendorLocations
419425
protected override void LoadDefaults()
420426
{
421427
autoUpdaterEnabled = true;
428+
showConvertToPrefabDialog = true;
422429
launchAfterInstallation = true;
423430
HideSendToUnityMenu = true;
424431
prefabSavePaths = new List<string>(){ kDefaultSavePath };

0 commit comments

Comments
 (0)