- Home /
Question by
reyonman · Jun 04, 2014 at 08:59 PM ·
editormeshcolliderduplicateaddcomponent
AddComponent() creating two colliders?
Unity 4.5.0f6
I'm adding a MeshCollider to an object via editor script and when the script is finished the result is two MeshCollider components. I have log writes in to confirm that the method isn't being called more than once. I've also ensured that collapse log is not enabled.
Other random info: the object is part of a prefab
Any thoughts?
Comment
Okay, so I discovered this was caused by the way that I was saving the prefab. I wasn't using ReplacePrefabOptions.ConnectToPrefab and when ReplacePrefab was called the duplicate would appear.
Any idea why? It looks like it was merging the instance into the prefab ins$$anonymous$$d of replacing it.
Your answer
![](https://koobas.hobune.stream/wayback/20220613150805im_/https://answers.unity.com/themes/thub/images/avi.jpg)