Skip to content

Commit 1fd2a33

Browse files
authored
Merge pull request #71 from Unity-Technologies/UNI-22860-bug-export-works-without-selection
UNI-22860 export happens even if nothing selected
2 parents 73e3ae7 + fc5633e commit 1fd2a33

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,15 @@ public void Dispose () { }
3333
public static void OnMenuItem ()
3434
{
3535
GameObject [] unityGameObjectsToConvert = Selection.GetFiltered<GameObject> (SelectionMode.Editable | SelectionMode.TopLevel);
36+
if (unityGameObjectsToConvert.Length <= 0) {
37+
ModelExporter.DisplayNoSelectionDialog ();
38+
return;
39+
}
40+
3641
Object[] result = CreateInstantiatedModelPrefab (unityGameObjectsToConvert);
37-
if (result.Length>0)
42+
if (result.Length > 0) {
3843
Selection.objects = result;
44+
}
3945
}
4046

4147
/// <summary>

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,10 @@ private void ReplaceFile ()
11121112
[MenuItem (MenuItemName, false)]
11131113
public static void OnMenuItem ()
11141114
{
1115+
if (Selection.objects.Length <= 0) {
1116+
DisplayNoSelectionDialog ();
1117+
return;
1118+
}
11151119
OnExport ();
11161120
}
11171121

@@ -1131,9 +1135,21 @@ public static bool OnValidateMenuItem ()
11311135
[MenuItem ("GameObject/Export Model...", false, 30)]
11321136
static void OnContextItem (MenuCommand command)
11331137
{
1138+
if (Selection.objects.Length <= 0) {
1139+
DisplayNoSelectionDialog ();
1140+
return;
1141+
}
11341142
OnExport ();
11351143
}
11361144

1145+
public static void DisplayNoSelectionDialog()
1146+
{
1147+
UnityEditor.EditorUtility.DisplayDialog (
1148+
"Fbx Exporter Warning",
1149+
"No GameObjects selected for export.",
1150+
"Ok");
1151+
}
1152+
11371153
//
11381154
// export mesh info from Unity
11391155
//

0 commit comments

Comments
 (0)