Skip to content

Commit 5d07447

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-22861-remove-menu-items-from-Assets
# Conflicts: # Assets/FbxExporters/Editor/ConvertToModel.cs # Assets/FbxExporters/Editor/FbxExporter.cs
2 parents 89be7c4 + 1fd2a33 commit 5d07447

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Editor
1818
{
1919
public class ConvertToModel : System.IDisposable
2020
{
21-
const string MenuItemName1 = "GameObject/Convert To Model";
21+
const string MenuItemName1 = "GameObject/Convert To Prefab";
2222

2323
/// <summary>
2424
/// Clean up this class on garbage collection
@@ -35,6 +35,10 @@ static void OnContextItem (MenuCommand command)
3535
// We were actually invoked from the top GameObject menu,
3636
// not the context menu, so treat it as such.
3737
GameObject [] unityGameObjectsToConvert = Selection.GetFiltered<GameObject> (SelectionMode.Editable | SelectionMode.TopLevel);
38+
if (unityGameObjectsToConvert.Length <= 0) {
39+
ModelExporter.DisplayNoSelectionDialog ();
40+
return;
41+
}
3842
Object[] result = CreateInstantiatedModelPrefab (unityGameObjectsToConvert);
3943
if (result.Length>0)
4044
Selection.objects = result;
@@ -123,7 +127,7 @@ public static GameObject[] CreateInstantiatedModelPrefab (GameObject [] unityGam
123127
Object unityMainAsset = AssetDatabase.LoadMainAssetAtPath("Assets/" + relativePath);
124128

125129
if (unityMainAsset != null) {
126-
Object unityObj = PrefabUtility.InstantiatePrefab (unityMainAsset);
130+
Object unityObj = PrefabUtility.InstantiatePrefab (unityMainAsset, gosToExport[i].scene);
127131
GameObject unityGO = unityObj as GameObject;
128132
if (unityGO != null)
129133
{

Assets/FbxExporters/Editor/FbxExporter.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,10 @@ private void ReplaceFile ()
11161116
[MenuItem (MenuItemName, false, 30)]
11171117
static void OnContextItem (MenuCommand command)
11181118
{
1119+
if (Selection.objects.Length <= 0) {
1120+
DisplayNoSelectionDialog ();
1121+
return;
1122+
}
11191123
OnExport ();
11201124
}
11211125

@@ -1128,6 +1132,13 @@ public static bool OnValidateMenuItem ()
11281132
return true;
11291133
}
11301134

1135+
public static void DisplayNoSelectionDialog()
1136+
{
1137+
UnityEditor.EditorUtility.DisplayDialog (
1138+
"Fbx Exporter Warning",
1139+
"No GameObjects selected for export.",
1140+
"Ok");
1141+
}
11311142
//
11321143
// export mesh info from Unity
11331144
//

Assets/FbxExporters/Editor/UnitTests/ModelExporterTest.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,19 @@ public void TestConvertToValidFilename()
123123
// test invalid filenames
124124
filename = "?foo**bar///.fbx";
125125
result = FbxExporters.Editor.ModelExporter.ConvertToValidFilename (filename);
126+
#if UNITY_EDITOR_WIN
126127
Assert.AreEqual ("_foo__bar___.fbx", result);
128+
#else
129+
Assert.AreEqual ("?foo**bar___.fbx", result);
130+
#endif
127131

128132
filename = "foo$?ba%r 2.fbx";
129133
result = FbxExporters.Editor.ModelExporter.ConvertToValidFilename (filename);
134+
#if UNITY_EDITOR_WIN
130135
Assert.AreEqual ("foo$_ba%r 2.fbx", result);
136+
#else
137+
Assert.AreEqual ("foo$?ba%r 2.fbx", result);
138+
#endif
131139
}
132140
}
133141
}

0 commit comments

Comments
 (0)