@@ -223,10 +223,6 @@ private static void SetupImportedGameObject(GameObject orig, GameObject imported
223
223
Transform importedTransform = imported . transform ;
224
224
Transform origTransform = orig . transform ;
225
225
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
-
230
226
// configure transform and maintain local pose
231
227
importedTransform . SetParent ( origTransform . parent , false ) ;
232
228
importedTransform . SetSiblingIndex ( origTransform . GetSiblingIndex ( ) ) ;
@@ -247,7 +243,10 @@ private static void SetupImportedGameObject(GameObject orig, GameObject imported
247
243
origTransform . hierarchyCount , importedTransform . hierarchyCount ) ) ;
248
244
}
249
245
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 ) ;
251
250
}
252
251
253
252
private static void FixSiblingOrder ( Transform orig , Transform imported ) {
@@ -265,8 +264,8 @@ private static void FixSiblingOrder(Transform orig, Transform imported){
265
264
}
266
265
}
267
266
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 ) {
270
269
Debug . LogError ( string . Format ( "Error: hierarchies don't match (From: {0}, To: {1})" , from . name , to . name ) ) ;
271
270
return ;
272
271
}
0 commit comments