Fix broken Prefab links / Replacing objects with Smart.Replace


Smart.Replace can help you to restore broken
prefab links or replace objects completely. In this case I have a button object where
the link to it’s prefab has been lost. I could just remove it an add the original
prefab to the scene, but then all values and references set for this object would be lost. In this example Smart.Replace helps me to
restore the prefab connection without losing the reference to the door. After installing the plugin, you can find
it under Window ->Replace Prefab… In this editor window we drop the button object
from the scene, and the corresponding prefab We can now ckeck the components and the values
we want to keep after the replacement. Unity components are disabled by default,
since they are supported yet. However, you can see the ButtonClick component
with the reference to the door, that we want to preserve. We dont really need the animator, it’s safe
to uncheck. After all settings were made, we can now hit
replace, and the prefab reference has been successfully restored – just like the reference
to the door. The actual use case i created Smart.Replace
for – is replacing placeholder objects in the later stages of game development. You see this button is kinda boring, so I
want to replace it with a much nicer version. We can do it just like before, by first dropping
the scene object, then the nicer prefab, setting the
values we want to transfer and then hitting replace. As you can see, we replaced our button with
a completely different prefab, and it still works! How about replacing the door now. This seems a bit tricky, since the door doesn’t
now it’s referenced by the button. But as you might have guessed, Smart.Replace
does. The process is the same again. We first select the scene object and then
the prefab. In this case we can ignore the door component,
since there are no relevat values to preserve. Maybe you have already noticed this toggle. If it is checked, we can ensure, that all
external references onto this object – or it’s components – will be preserved. Again we hit replace, now the door has been
changed and – the button still has the same reference onto the door – it’s that easy. If you have mutiple similar objects in the
scene that you want to replace, it would be tedious to do it one by one. Smart.Replace offers search for similar objects,
so we can replace any number of objects at once. First we select any of the objects in the
scene and then a prefab – so we can search for similar objects. By default there are no filters, so all objects
in the scene are shown. Search by name is very efficient in this case,
since all buttons have similar names. You could also search for components. If we now hit replace, we see that all objects
are replaced at once. If they had references onto each other, they
would have also been preserved. Thats all i have to show for now. I hope anyone finds this plugin to be helpful. You can find a download link in the description. It’s also open source, so you’re free to tinker
with it if you like. Thanks for watching, bye.

Leave a Reply

Your email address will not be published. Required fields are marked *