Unity | Error – Prefab has multiple Transform components!

We were getting the following error message that was causing a hard crash in Unity3D.

Prefab has multiple Transform components! Removing them automatically would not be safe.
UnityEditor.AssetDatabase:Refresh(ImportAssetOptions)
UnityEditor.AssetDatabase:Refresh()

This is a default asset.  Use the 'Assets -> Reimport' menu command to try importing it again, or you can replace the asset and it will auto import.
This is a default asset. Use the ‘Assets -> Reimport’ menu command to try importing it again, or you can replace the asset and it will auto import.
In the rush of a milestone delivery, we narrowed it down to a particular Prefab and verified that when a user received the error, doing a Perforce “Force Sync” would prevent the asset from causing a crash. Later, when upgrading to a new version of Unity, we got the same error during the upgrade, resulting in the file being skipped and requiring a manual reimport.

Multiple Transforms? How?

Okay, so how is it possible for one of our prefabs to have multiple Transform components?

A little more investigation revealed that a developer’s use of Perforce merge changes (resolve conflicts) was actually the culprit. That is, when merging changes in the prefab (a text-based YAML file), the merge actually duplicated the transform instead of replacing the previous.

Perforce Merge of YAML Created Duplicate Transforms
Perforce Merge of YAML Created Duplicate Transforms

This is both totally understandable and surprising that it doesn’t happen more often. A nice reminder that merging prefabs can be dangerous (since Perforce merge-logic isn’t written for merging YAML.)

Here’s to hoping this helps anyone else encountering the same error.

2D Graphics Programming for Games [book] ThumbnailFor more topics on 2D graphics programming, be sure to check out my book, 2D Graphics Programming for Games available now both online and through your favorite independent bookseller.

2 comments on “Unity | Error – Prefab has multiple Transform components!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.