- Home /
Prefabs loose connection to scene object
So I am trying to use EditorUtility.ReplacePrefab(), but when I select scene objects they become missing when I reenter play mode. I noticed I can select Prefabs in the assets and used GameObject.Find to set it to a scene object at the start, but this isnt really ideal. Is there a way to keep the connection/reference to the scene object? Thanks for your help.
Answer by Bunny83 · Oct 29, 2011 at 10:28 PM
No, that's not possible because prefabs are assets and they can't rely on objects in a certain scene.
When you instantiate the prefab, what would you expect when the scene with the referenced object isn't loaded?
Well I am making a tool so trying to make it as advance as possible. This way should work just have to create prefabs for every objects I guess.
Prefabs are like blueprints. They specify how the object should look like when it's created. Imagine a blueprint of a house. What you want to do is to connect the electrical house connection to the blueprint itself so when you build the house it's already connected.
Prefabs can reference other prefabs but not concrete instances of a prefab (like you have in a scene)
Yeah, so for what I want and I dont know why I didnt realize it was just to set a temp Object to the orinal asset then used the GameObject.Find to manipulate the scene object and after the event set it back to the oringal Assets this allows it to be edited later without the Scene object saved. If it doesnt make sense its not a major concern it does to me :)
Your answer
![](https://koobas.hobune.stream/wayback/20220613024511im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
PrefabUtility.ReplacePrefab trouble 0 Answers
Sending cubes to prefab makes their mesh settings vanish 2 Answers
The Script Equivilent of dragging a hierarchy of meshes over a preexisting prefab? 0 Answers
adapting replace prefab example 1 Answer
How to (in code) save a gameobject that already exists in my scene as a prefab? (c#) 0 Answers