Skip to content

Commit 89be7c4

Browse files
committed
remove menu items from under Assets
1 parent 0067b34 commit 89be7c4

File tree

2 files changed

+27
-43
lines changed

2 files changed

+27
-43
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,26 @@ namespace Editor
1818
{
1919
public class ConvertToModel : System.IDisposable
2020
{
21-
const string MenuItemName1 = "Assets/Convert To Model";
22-
const string MenuItemName2 = "GameObject/Convert To Model";
21+
const string MenuItemName1 = "GameObject/Convert To Model";
2322

2423
/// <summary>
2524
/// Clean up this class on garbage collection
2625
/// </summary>
2726
public void Dispose () { }
2827

29-
/// <summary>
30-
/// create menu item in the File menu
31-
/// </summary>
32-
[MenuItem (MenuItemName1, false)]
33-
public static void OnMenuItem ()
34-
{
35-
GameObject [] unityGameObjectsToConvert = Selection.GetFiltered<GameObject> (SelectionMode.Editable | SelectionMode.TopLevel);
36-
Object[] result = CreateInstantiatedModelPrefab (unityGameObjectsToConvert);
37-
if (result.Length>0)
38-
Selection.objects = result;
39-
}
40-
41-
/// <summary>
42-
// Validate the menu item defined by the function above.
43-
/// </summary>
44-
[MenuItem (MenuItemName1, true)]
45-
public static bool OnValidateMenuItem ()
46-
{
47-
return true;
48-
}
49-
5028
// Add a menu item called "Export Model..." to a GameObject's context menu.
5129
// OnContextItem gets called once per selected object
5230
// (if the parent and child are selected, then OnContextItem will only be called on the parent)
53-
[MenuItem (MenuItemName2, false, 30)]
31+
[MenuItem (MenuItemName1, false, 30)]
5432
static void OnContextItem (MenuCommand command)
5533
{
5634
if (command == null || command.context == null) {
5735
// We were actually invoked from the top GameObject menu,
5836
// not the context menu, so treat it as such.
59-
OnMenuItem();
37+
GameObject [] unityGameObjectsToConvert = Selection.GetFiltered<GameObject> (SelectionMode.Editable | SelectionMode.TopLevel);
38+
Object[] result = CreateInstantiatedModelPrefab (unityGameObjectsToConvert);
39+
if (result.Length>0)
40+
Selection.objects = result;
6041
return;
6142
}
6243

@@ -65,12 +46,21 @@ static void OnContextItem (MenuCommand command)
6546
Debug.LogError (string.Format("Error: {0} is not a GameObject and cannot be converted", command.context.name));
6647
return;
6748
}
68-
GameObject[] result = CreateInstantiatedModelPrefab (new GameObject[]{selected});
69-
if (result.Length>0)
70-
Selection.objects = result;
49+
GameObject[] result1 = CreateInstantiatedModelPrefab (new GameObject[]{selected});
50+
if (result1.Length>0)
51+
Selection.objects = result1;
7152

7253
}
7354

55+
/// <summary>
56+
// Validate the menu item defined by the function above.
57+
/// </summary>
58+
[MenuItem (MenuItemName1, true, 30)]
59+
public static bool OnValidateMenuItem ()
60+
{
61+
return true;
62+
}
63+
7464
/// <summary>
7565
/// Create an instantiated model prefab from an game object hierarchy.
7666
/// </summary>

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ public class ModelExporter : System.IDisposable
3232

3333
const string ReadmeRelativePath = "FbxExporters/README.txt";
3434

35-
const string MenuItemName = "Assets/Export Model...";
35+
// NOTE: The ellipsis at the end of the Menu Item name prevents the context
36+
// from being passed to command, thus resulting in OnContextItem()
37+
// being called only once regardless of what is selected.
38+
const string MenuItemName = "GameObject/Export Model...";
3639

3740
const string FileBaseName = "Untitled";
3841

@@ -1107,33 +1110,24 @@ private void ReplaceFile ()
11071110
}
11081111

11091112
/// <summary>
1110-
/// create menu item in the File menu
1113+
/// Add a menu item to a GameObject's context menu.
11111114
/// </summary>
1112-
[MenuItem (MenuItemName, false)]
1113-
public static void OnMenuItem ()
1115+
/// <param name="command">Command.</param>
1116+
[MenuItem (MenuItemName, false, 30)]
1117+
static void OnContextItem (MenuCommand command)
11141118
{
11151119
OnExport ();
11161120
}
11171121

11181122
/// <summary>
11191123
// Validate the menu item defined by the function above.
11201124
/// </summary>
1121-
[MenuItem (MenuItemName, true)]
1125+
[MenuItem (MenuItemName, true, 30)]
11221126
public static bool OnValidateMenuItem ()
11231127
{
11241128
return true;
11251129
}
11261130

1127-
// Add a menu item called "Export Model..." to a GameObject's context menu.
1128-
// NOTE: The ellipsis at the end of the Menu Item name prevents the context
1129-
// from being passed to command, thus resulting in OnContextItem()
1130-
// being called only once regardless of what is selected.
1131-
[MenuItem ("GameObject/Export Model...", false, 30)]
1132-
static void OnContextItem (MenuCommand command)
1133-
{
1134-
OnExport ();
1135-
}
1136-
11371131
//
11381132
// export mesh info from Unity
11391133
//

0 commit comments

Comments
 (0)