- Home /
How can you duplicate a prefab and sever all links to the original?
I have a prefab set up (a single game object with various scripts and other components attached). I would like to create a second prefab that is identical to the first, except for the shader. What is the easiest way of doing this? I originally hoped to instantiate the prefab, then 'break prefab instance', rename it (or duplicate it), and create a new prefab from that object. However, although I end up with two prefabs, they seem to still be linked in some way; if I change the shader on one, it seems to get changed on both. I've also tried just copying the prefab on disk, but the resulting object appears white in the project view instead of blue, and appears to be unusable (dragging to the scene is not permitted).
Is there perhaps some way of severing all links of a prefab instance such that it will no longer be associated with the prefab at all? Or is there some other way of achieving what I need? Thanks in advance,
Andy
I had a couple of further thoughts on this. Firstly, for the specific case I indicate above, I would maybe be better off using a single prefab and simply modifying the shader on the specific instances that need it - that way the 'common part' of the prefab would not need to be duplicated. However, for my case, I actually want to introduce a variety of differences between the prefabs, so that solution is not so convenient.
Secondly, I think a more elegant solution would be available if nested prefabs were supported (which I understand will be available in 4.X). Anyone happen to know when / what precise release it is due to land in?
Answer by Loius · Mar 23, 2013 at 09:58 AM
Your method is correct, but materials are their own object. A mesh links to an existing material, and like as not your two prefabs are linked to the same material. You need to duplicate the material (and make changes as necessary) and assign the new material to the new prefab.
Ah, I see. $$anonymous$$akes sense; I think it was the fact that the properties of the material were editable via the inspector of the object it was attached made me think that those settings were per object. Thanks!
Yeah, I've thought the same thing on multiple occasions and caught myself with exactly the same thing you were doing. :)