Search Issue Tracker

By Design

Votes

0

Found in

2018.3.0a6

2019.1.0a1

2019.1.0f2

2019.2.0a1

2019.3.0a1

Issue ID

1153192

Regression

Yes

[RequireComponent] can cause duplicate components to be created on prefabs

Scene Management

-

How to reproduce:
1. Create a new Unity project
2. Create a GameObject
3. Add the Animator component
4. Save that object as a prefab
5. Instantiate this prefab in a scene
6. Remove the Animator component on the instance (it will be marked as Animator (Removed))
7. Add a new component that has the attribute [RequireComponent(typeof(Animator))]

Expected result: only one Animator Component is on the GameObject instance
Actual result: a new Animator component that cannot be removed is added and one cannot revert the removed Animator component from the instance

Reproducible with: 2018.3.0a6, 2018.4.1f1, 2019.1.3f1, 2019.2.0b3, 2019.3.0a3
Not reproducible with: 2017.4.27f1, 2018.3.0a5(Uses the old Prefab system)

  1. Resolution Note:

    There can be only one Animator component on a GameObject at a time, so the removed one cannot be reverted (which recreates it) while there is a new one. At the same time, the new one can’t be removed as long as there is another component, which requires it. These things are both by design. To remove the new Animator and reinstate the old Animator, you will have to first remove the component which requires the Animator. Then you can remove the new added Animator and revert (reinstate) the removed original Animator. There is not a feature to be able to do this without removing the component that depends on an Animator.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.