Prefabs Linking to Prefabs in a Scene

Hi there, I have several prefabs in my scene that refer to other prefabs which I attach via the inspector. When I drag a prefab into the scene, is there anyway preserve the links to these other prefabs without having to re-establish them every time? I could establish them in code, but for the moment, I’d like to do this via the inspector.


I get a bit confused with what you wrote. Did you mean that you drag a game object from the scene into the project (making a prefab) and that references to the objects in the scene become invalid?

Example of what I think you mean:

  1. GameObject A has script that references GameObject B.
  2. A and B are in the scene.
  3. You make a prefab out of A by dragging it from the hierarchy to the project.
  4. Prefab of A loses link to B.

In this case you have some asset in the project that references an asset in a particular scene. If you were to change scene and instantiate that object then there is no chance to reconnect to the object since it doesn’t exist in the scope of objects that it can access.

Otherwise please explain your problem a little more in detail as I can’t figure out what you mean.

Spawning a prefab (in code or dragging it into the scene) does preserve links to other prefabs. You are probably missing Step#3 (from statement’s answer,) where you drag it back over the old prefab, to “copy back” the changes.

You should then see your prefab, in project view, with the script slot now filled in with the prefab. Again, perfectly normal to have a prefab orc with links to the prefab blood and arrows it will fire.

You probably could just drag it in Project. But there are some changes (like rearranging children) that can’t be done directly to a prefab. Plus I like to test it. So I’m in the habit of always dragging the PF into the scene, make changes, drag back to copy (the sequence statement listed.)

Not what you asked, but prefabs can’t have links to existing gameObjects. If you want those on any spawned prefabs, you will have to toss in something like Transform player = GameObject.Find("player");.