- Home /
Copy clone in prefab
Hello everyone !
I have prefabs with some datas (ints, strings...) and I have a Clone of this prefab. In this clone, I modify some of those ints and strings.
And after that I want to copy my Clone in the prefab, I mean that I want my prefab to have the same properties of my clone object. I found :
UnityEditor.PrefabUtility.ReplacePrefab
but this is only functional in the editor. Can you help me ? Another thing is that I don't want to copy manualy the datas. Thanks a lot !
Do you mean changing the value at runtime (during the game) or in the editor?
Answer by Bunny83 · Jul 27, 2012 at 11:07 AM
At runtime a prefab is a seperate object and don't belong to the clone in any case. Prefabs are just pre initialized objects that can be cloned. You can change the values on the prefab object directly, but you can't merge two different objects.
If you really want to create an instance, modify it and then copy the values to the prefab, the only way is to copy them manually.
Prefabs are an editor-only feature (until now). At runtime they are just gameobject that aren't in the scene.
Also keep in mind you can clone / instantiate any kind of object, it doesn't have to be an off-scene "prefab" object. You can clone other gameobjects as well.
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
After Build, instantiate does not work 1 Answer
Instantiate prefab 1 Answer
Duplicate project to create Demo Version 1 Answer
Instantiate Reference Problem 1 Answer