I know I can replace a prefab with a game object, but can I do the reverse? Meaning, I want to keep the same settings, at LEAST the transform, of the GO, but replace it with a prefab.
Would make importing game objects to other scenes a little more do-able.
If I’m not mistaken, this is actually default behaviour. A prefab instance always has its transform settings as “overriden”. So you can move the instance around, then change the prefab, and the instance will take on all settings from the prefab, except its transform settings.
I don’t want to change settings on the prefab. I want to REPLACE the ENTIRE prefab with another.
Example:
I make a nice particle effect. I place this in the scene in several places. Then, my partner makes a better effect on his computer. I want to replace my particles with his, so I copy his prefab to my project.
But now, there is no way for me (that I know of!) to replace my prefab with his.
Now the hard part: say you have a game object that contains one or more objects that you want to replace with prefabs. Think of them as place-holder objects. Now I want to replace the place-holders with prefabs, but without having to copy/paste all the params around. Is there a way to do that?
Hey,
i had the same problem and wrote a little script to fix it.
Its realy not that hard as I thougt ^^
What it does:
The script lets you replace a hole bunch of placeholders at the same by an predefined Prefab.
The object you put in for replacing needs to be a Prefab.
If you want to replace many placeholders at the same time, attach them as children to another Object. For example an
Empty. Then declare this Parent as the object to replace.
The script will automaticly check for its children an replace them.
Feel free to do some improvements on the script. But please be fair enough to share it.
So others could benefit of it.
Heya guys,
I’m having a hard time trying to get this to work in my situation. The alt drag doesn’t work for either. It says that this is not implemented yet. As for the script it says it can’t find the prefab in the prefab library. any ideas?
Same Here (3.5.2) - Alt-dragging a prefab from Project into a different prefab in Hierachy does not swap in the new prefab. It does nothing. (And occasionally crashes.) I don’t need the script and didn’t try it, but dragging manually would be great!
Yeah, sorry guys, I also don’t know how to make this work. I’ve created a new script (CopyComponents.cs), and the Custom > ReplaceGameObjects menu shows up…but when I try to use the option, I get a “NullReferenceException: Object reference not set to an instance of an object” error. What am I doing wrong?