- Home /
Is there a quick way to replace an object with a prefab instance?
Hi all. I've messed up slightly.
I've placed many copies of a model, and then turned one of them into a prefab. What i have now is a single instance of that prefab, and a bunch of identical instances of the model the prefab is based on.
What i'd like to do is turn all those instances of the model, into instances of the prefab.
I can do this by just noting down the transforms, manually deleting them, dragging in a prefab instance, and re-entering the position/rotation. But that would be time consuming to do many times over. I'm wondering if there's some better way to do this en-masse, or even just to speed up the process per-instance.
You could write an editor script to help! To my knowledge, there's no built-in way to accomplish this with great ease. If it saves work, write a script - if it'd take less work to change each one manually, do that.
Answer by MrSoad · Nov 04, 2014 at 11:20 PM
Try this, it worked for me when I did this ages ago.
1) Create a new prefab(A).
2) Rename the one that is a prefab to something different(B). Delete from scene after doing this.
3) Drag each of your objects from the hierarchy window onto this new prefab(A), one at a time. The order in the Hierarchy window will change as you do so be careful to take this into account(as these are not currently prefabs then you can use the text color to tell which ones you have done). Yes to replace for each one when the box pops up.
4) When you have associated all these objects with the new prefab(A) drag the original prefab(B) object onto this prefab(A) and again click yes.
5) Now with a bit of luck they should all be associated to one prefab(A) whilst keeping their transform position in the scene. To test if you have got them all change the scale of the prefab, if they all adjust then you have got them all.
This will reset scale, however it will at least keep both the position and rotation :)