@@ -18,45 +18,26 @@ namespace Editor
18
18
{
19
19
public class ConvertToModel : System . IDisposable
20
20
{
21
- const string MenuItemName1 = "Assets/Convert To Model" ;
22
- const string MenuItemName2 = "GameObject/Convert To Model" ;
21
+ const string MenuItemName1 = "GameObject/Convert To Model" ;
23
22
24
23
/// <summary>
25
24
/// Clean up this class on garbage collection
26
25
/// </summary>
27
26
public void Dispose ( ) { }
28
27
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
-
50
28
// Add a menu item called "Export Model..." to a GameObject's context menu.
51
29
// OnContextItem gets called once per selected object
52
30
// (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 ) ]
54
32
static void OnContextItem ( MenuCommand command )
55
33
{
56
34
if ( command == null || command . context == null ) {
57
35
// We were actually invoked from the top GameObject menu,
58
36
// 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 ;
60
41
return ;
61
42
}
62
43
@@ -65,12 +46,21 @@ static void OnContextItem (MenuCommand command)
65
46
Debug . LogError ( string . Format ( "Error: {0} is not a GameObject and cannot be converted" , command . context . name ) ) ;
66
47
return ;
67
48
}
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 ;
71
52
72
53
}
73
54
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
+
74
64
/// <summary>
75
65
/// Create an instantiated model prefab from an game object hierarchy.
76
66
/// </summary>
0 commit comments