Skip to content

Commit e4b8f87

Browse files
authored
Merge pull request #55 from Unity-Technologies/UNI-21964-model-name-matches-filename
UNI-21965 Convert to Model imported object name matches filename
2 parents 51ce74e + eb6bf4d commit e4b8f87

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Assets/FbxExporters/Editor/ConvertToModel.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@ private static void SetupImportedGameObject(GameObject orig, GameObject imported
223223
Transform importedTransform = imported.transform;
224224
Transform origTransform = orig.transform;
225225

226-
// Set the name to be the name of the instantiated asset.
227-
// This will get rid of the "(Clone)" if it's added
228-
imported.name = orig.name;
229-
230226
// configure transform and maintain local pose
231227
importedTransform.SetParent (origTransform.parent, false);
232228
importedTransform.SetSiblingIndex (origTransform.GetSiblingIndex());
@@ -247,7 +243,10 @@ private static void SetupImportedGameObject(GameObject orig, GameObject imported
247243
origTransform.hierarchyCount, importedTransform.hierarchyCount));
248244
}
249245
FixSiblingOrder (orig.transform, imported.transform);
250-
CopyComponentsRecursive (orig, imported);
246+
247+
// the imported GameObject will have the same name as the file to which it was imported from,
248+
// which might not be the same name as the original GameObject
249+
CopyComponentsRecursive (orig, imported, namesExpectedMatch:false);
251250
}
252251

253252
private static void FixSiblingOrder(Transform orig, Transform imported){
@@ -265,8 +264,8 @@ private static void FixSiblingOrder(Transform orig, Transform imported){
265264
}
266265
}
267266

268-
private static void CopyComponentsRecursive(GameObject from, GameObject to){
269-
if (!to.name.StartsWith(from.name) || from.transform.childCount != to.transform.childCount) {
267+
private static void CopyComponentsRecursive(GameObject from, GameObject to, bool namesExpectedMatch = true){
268+
if (namesExpectedMatch && !to.name.StartsWith(from.name) || from.transform.childCount != to.transform.childCount) {
270269
Debug.LogError (string.Format("Error: hierarchies don't match (From: {0}, To: {1})", from.name, to.name));
271270
return;
272271
}

0 commit comments

Comments
 (0)