Skip to content

Commit 543ecad

Browse files
committed
remove EnforceUniqueNames from ConvertToModel
- already creating unique names in the FbxExporter - Make convert take ConvertToPrefabSettingsSerialize instead of ExportOptions to avoid being able to use the regular export options for linked prefabs
1 parent 03a8ade commit 543ecad

File tree

2 files changed

+1
-49
lines changed

2 files changed

+1
-49
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public static GameObject Convert (
104104
string fbxFullPath = null,
105105
string prefabDirectoryFullPath = null,
106106
string prefabFullPath = null,
107-
EditorTools.IExportOptions exportOptions = null
107+
EditorTools.ConvertToPrefabSettingsSerialize exportOptions = null
108108
)
109109
{
110110
// Only create the prefab (no FBX export) if we have selected the root of a model prefab instance.
@@ -135,12 +135,6 @@ public static GameObject Convert (
135135
}
136136
var projectRelativePath = EditorTools.ExportSettings.GetProjectRelativePath (fbxFullPath);
137137

138-
// Make sure that the object names in the hierarchy are unique.
139-
// The import back in to Unity would do this automatically but
140-
// we prefer to control it so that the Maya artist can see the
141-
// same names as exist in Unity.
142-
EnforceUniqueNames (new GameObject[] {toConvert});
143-
144138
// Export to FBX. It refreshes the database.
145139
{
146140
var fbxActualPath = ModelExporter.ExportObject (
@@ -274,35 +268,6 @@ public static string IncrementFileName(string path, string filename)
274268
return file;
275269
}
276270

277-
/// <summary>
278-
/// Enforces that all object names be unique before exporting.
279-
/// If an object with a duplicate name is found, then it is incremented.
280-
/// e.g. Sphere becomes Sphere 1
281-
/// </summary>
282-
/// <param name="exportSet">Export set.</param>
283-
public static void EnforceUniqueNames(IEnumerable<GameObject> exportSet)
284-
{
285-
Dictionary<string, int> NameToIndexMap = new Dictionary<string, int> ();
286-
string format = "{0} {1}";
287-
288-
Queue<GameObject> queue = new Queue<GameObject> (exportSet);
289-
290-
while(queue.Count > 0){
291-
var go = queue.Dequeue ();
292-
var name = go.name;
293-
if (NameToIndexMap.ContainsKey (name)) {
294-
go.name = string.Format (format, name, NameToIndexMap [name]);
295-
NameToIndexMap [name]++;
296-
} else {
297-
NameToIndexMap [name] = 1;
298-
}
299-
300-
foreach (Transform child in go.transform) {
301-
queue.Enqueue (child.gameObject);
302-
}
303-
}
304-
}
305-
306271
/// <summary>
307272
/// Updates the meshes and materials of the exported GameObjects
308273
/// to link to those imported from the FBX.

Assets/FbxExporters/Editor/UnitTests/ConvertToModelTest.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,6 @@ public void TestStaticHelpers()
4545
Assert.AreEqual (filename2, ConvertToModel.IncrementFileName (tempPath, filename1));
4646
}
4747

48-
// Test EnforceUniqueNames
49-
{
50-
var a = new GameObject("a");
51-
var b = new GameObject("b");
52-
var a1 = new GameObject("a");
53-
var a2 = new GameObject("a");
54-
ConvertToModel.EnforceUniqueNames(new GameObject[] { a, b, a1, a2 });
55-
Assert.AreEqual("a", a.name);
56-
Assert.AreEqual("b", b.name);
57-
Assert.AreEqual("a 1", a1.name);
58-
Assert.AreEqual("a 2", a2.name);
59-
}
60-
6148
// Test CopyComponents
6249
{
6350
var a = GameObject.CreatePrimitive (PrimitiveType.Cube);

0 commit comments

Comments
 (0)