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
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)
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Some UXML Template Asset foldouts appear enabled when all fields inside are disabled
- URP Terrain Demo crash on burst_signal_handler after Generating lighting
- Project window button icons are poorly visible and their shades differ in Light theme
- GC.Alloc called by HDRenderPipeline.LensFlareMergeOcclusionDataDrivenPass() when playing the default HDRP Sample Template project
- Automatic LOD fails and SRP Batcher incompatibility occurs when using spline-based quad-topology meshes
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.