Skip to content

Commit 8df5c5a

Browse files
committed
Merge remote-tracking branch 'refs/remotes/origin/master' into UNI-25505-single-root-package
# Conflicts: # Assets/FbxExporters/Editor/InstallIntegration.cs # Assets/FbxExporters/Integrations/Autodesk/maya/icons/unity_100.png # Assets/FbxExporters/Integrations/Autodesk/maya/icons/unity_150.png # Assets/FbxExporters/Integrations/Autodesk/maya/icons/unity_200.png # Assets/Integrations/Autodesk/maya/icons/unity.png # Assets/Integrations/Autodesk/maya/icons/unity_200.png
2 parents 184be9a + 119ae7e commit 8df5c5a

26 files changed

+639
-322
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Executable + Temp files ##
22
*.exe
33
*.exe.*
4+
!BringToFront.exe
45
*.o
56
*.pdb
67
*.mdb

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Editor
1818
{
1919
public static class ConvertToModel
2020
{
21-
const string MenuItemName1 = "GameObject/Convert To Prefab";
21+
const string MenuItemName1 = "GameObject/Convert To Linked Prefab Instance";
2222

2323
/// <summary>
2424
/// OnContextItem is called either:
@@ -62,6 +62,23 @@ public static bool OnValidateMenuItem ()
6262
return true;
6363
}
6464

65+
/// <summary>
66+
/// After a convert-to-model, we normally delete the original object.
67+
/// That can be overridden.
68+
/// </summary>
69+
public enum KeepOriginal {
70+
Default, // Use the export settings.
71+
Keep, // Don't delete, just rename it.
72+
Delete, // Delete the original hierarchy.
73+
}
74+
75+
/// <summary>
76+
/// Gets the export settings.
77+
/// </summary>
78+
public static EditorTools.ExportSettings ExportSettings {
79+
get { return EditorTools.ExportSettings.instance; }
80+
}
81+
6582
/// <summary>
6683
/// Create instantiated model prefabs from a selection of objects.
6784
///
@@ -73,7 +90,10 @@ public static bool OnValidateMenuItem ()
7390
/// <param name="unityGameObjectsToConvert">Unity game objects to convert to Model Prefab instances</param>
7491
/// <param name="path">Path to save Model Prefab; use FbxExportSettings if null</param>
7592
/// <param name="keepOriginal">If set to <c>true</c> keep original gameobject hierarchy.</param>
76-
public static GameObject[] CreateInstantiatedModelPrefab (GameObject [] unityGameObjectsToConvert, string directoryFullPath = null, bool keepOriginal = true)
93+
public static GameObject[] CreateInstantiatedModelPrefab (
94+
GameObject [] unityGameObjectsToConvert,
95+
string directoryFullPath = null,
96+
KeepOriginal keepOriginal = KeepOriginal.Default)
7797
{
7898
if (directoryFullPath == null) {
7999
directoryFullPath = FbxExporters.EditorTools.ExportSettings.GetAbsoluteSavePath();
@@ -119,7 +139,7 @@ public static GameObject Convert (
119139
GameObject toConvert,
120140
string directoryFullPath = null,
121141
string fbxFullPath = null,
122-
bool keepOriginal = true)
142+
KeepOriginal keepOriginal = KeepOriginal.Default)
123143
{
124144
if (string.IsNullOrEmpty(fbxFullPath)) {
125145
// Generate a unique filename.
@@ -197,7 +217,20 @@ public static GameObject Convert (
197217
unityGO = PrefabUtility.ConnectGameObjectToPrefab(unityGO, prefab);
198218

199219
// Remove (now redundant) gameobject
200-
if (!keepOriginal) {
220+
bool actuallyKeepOriginal;
221+
switch(keepOriginal) {
222+
case KeepOriginal.Delete:
223+
actuallyKeepOriginal = false;
224+
break;
225+
case KeepOriginal.Keep:
226+
actuallyKeepOriginal = true;
227+
break;
228+
case KeepOriginal.Default:
229+
default:
230+
actuallyKeepOriginal = ExportSettings.keepOriginalAfterConvert;
231+
break;
232+
}
233+
if (!actuallyKeepOriginal) {
201234
Object.DestroyImmediate (toConvert);
202235
} else {
203236
// rename and put under scene root in case we need to check values
@@ -218,6 +251,7 @@ public static string IncrementFileName(string path, string filename)
218251
{
219252
string fileWithoutExt = Path.GetFileNameWithoutExtension (filename);
220253
string ext = Path.GetExtension (filename);
254+
// file, space, number, extension.
221255
string format = "{0} {1}{2}";
222256

223257
int index = 1;
@@ -226,10 +260,15 @@ public static string IncrementFileName(string path, string filename)
226260
var result = System.Text.RegularExpressions.Regex.Match(fileWithoutExt, @"\d+$");
227261
if (result != null) {
228262
var number = result.Value;
263+
264+
// Parse the number.
229265
int tempIndex;
230266
if (int.TryParse (number, out tempIndex)) {
231267
fileWithoutExt = fileWithoutExt.Remove (fileWithoutExt.LastIndexOf (number));
232-
format = "{0}{1}{2}"; // remove space from format
268+
// Change the format to remove the extra space we'd add
269+
// if there weren't already a number. Also, try to use the
270+
// same width (so Cube001 increments to Cube002, not Cube2).
271+
format = "{0}{1:D" + number.Length + "}{2}"; // file, number with padding, extension
233272
index = tempIndex+1;
234273
}
235274
}
@@ -350,6 +389,15 @@ private static void CopyComponentsRecursive(GameObject from, GameObject to, bool
350389
public static void CopyComponents(GameObject from, GameObject to){
351390
var originalComponents = new List<Component>(to.GetComponents<Component> ());
352391
foreach(var component in from.GetComponents<Component> ()) {
392+
// UNI-24379: we don't support SkinnedMeshRenderer right
393+
// now: we just bake the mesh into its current pose. So
394+
// don't copy the SMR over. There will already be a
395+
// MeshFilter and MeshRenderer due to the static mesh.
396+
// Remove this code when we support skinning.
397+
if (component is SkinnedMeshRenderer) {
398+
continue;
399+
}
400+
353401
var json = EditorJsonUtility.ToJson(component);
354402

355403
System.Type expectedType = component.GetType();

0 commit comments

Comments
 (0)