File tree Expand file tree Collapse file tree 3 files changed +25
-2
lines changed
Assets/FbxExporters/Editor Expand file tree Collapse file tree 3 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ namespace Editor
18
18
{
19
19
public class ConvertToModel : System . IDisposable
20
20
{
21
- const string MenuItemName1 = "GameObject/Convert To Model " ;
21
+ const string MenuItemName1 = "GameObject/Convert To Prefab " ;
22
22
23
23
/// <summary>
24
24
/// Clean up this class on garbage collection
@@ -35,6 +35,10 @@ static void OnContextItem (MenuCommand command)
35
35
// We were actually invoked from the top GameObject menu,
36
36
// not the context menu, so treat it as such.
37
37
GameObject [ ] unityGameObjectsToConvert = Selection . GetFiltered < GameObject > ( SelectionMode . Editable | SelectionMode . TopLevel ) ;
38
+ if ( unityGameObjectsToConvert . Length <= 0 ) {
39
+ ModelExporter . DisplayNoSelectionDialog ( ) ;
40
+ return ;
41
+ }
38
42
Object [ ] result = CreateInstantiatedModelPrefab ( unityGameObjectsToConvert ) ;
39
43
if ( result . Length > 0 )
40
44
Selection . objects = result ;
@@ -123,7 +127,7 @@ public static GameObject[] CreateInstantiatedModelPrefab (GameObject [] unityGam
123
127
Object unityMainAsset = AssetDatabase . LoadMainAssetAtPath ( "Assets/" + relativePath ) ;
124
128
125
129
if ( unityMainAsset != null ) {
126
- Object unityObj = PrefabUtility . InstantiatePrefab ( unityMainAsset ) ;
130
+ Object unityObj = PrefabUtility . InstantiatePrefab ( unityMainAsset , gosToExport [ i ] . scene ) ;
127
131
GameObject unityGO = unityObj as GameObject ;
128
132
if ( unityGO != null )
129
133
{
Original file line number Diff line number Diff line change @@ -1116,6 +1116,10 @@ private void ReplaceFile ()
1116
1116
[ MenuItem ( MenuItemName , false , 30 ) ]
1117
1117
static void OnContextItem ( MenuCommand command )
1118
1118
{
1119
+ if ( Selection . objects . Length <= 0 ) {
1120
+ DisplayNoSelectionDialog ( ) ;
1121
+ return ;
1122
+ }
1119
1123
OnExport ( ) ;
1120
1124
}
1121
1125
@@ -1128,6 +1132,13 @@ public static bool OnValidateMenuItem ()
1128
1132
return true ;
1129
1133
}
1130
1134
1135
+ public static void DisplayNoSelectionDialog ( )
1136
+ {
1137
+ UnityEditor . EditorUtility . DisplayDialog (
1138
+ "Fbx Exporter Warning" ,
1139
+ "No GameObjects selected for export." ,
1140
+ "Ok" ) ;
1141
+ }
1131
1142
//
1132
1143
// export mesh info from Unity
1133
1144
//
Original file line number Diff line number Diff line change @@ -123,11 +123,19 @@ public void TestConvertToValidFilename()
123
123
// test invalid filenames
124
124
filename = "?foo**bar///.fbx" ;
125
125
result = FbxExporters . Editor . ModelExporter . ConvertToValidFilename ( filename ) ;
126
+ #if UNITY_EDITOR_WIN
126
127
Assert . AreEqual ( "_foo__bar___.fbx" , result ) ;
128
+ #else
129
+ Assert . AreEqual ( "?foo**bar___.fbx" , result ) ;
130
+ #endif
127
131
128
132
filename = "foo$?ba%r 2.fbx" ;
129
133
result = FbxExporters . Editor . ModelExporter . ConvertToValidFilename ( filename ) ;
134
+ #if UNITY_EDITOR_WIN
130
135
Assert . AreEqual ( "foo$_ba%r 2.fbx" , result ) ;
136
+ #else
137
+ Assert . AreEqual ( "foo$?ba%r 2.fbx" , result ) ;
138
+ #endif
131
139
}
132
140
}
133
141
}
You can’t perform that action at this time.
0 commit comments