- Home /
Script to rewire gameobjects to prefabs?
I goofed up and when looking back at some of my thousands of game scene objects, somehow they lost their prefab connection.
They aren't real prefab instances in Unity's eyes, but they have all the same components, and only vary by a few data, so I was thinking it might be easier to write a script to recreate the scene graph with my list of known prefabs.
So basically my Q is: how do we, at editor time, instantiate prefabs on the scene graphs so that they mantain their prefab connections ?
Answer by DaveA · Sep 03, 2011 at 12:24 AM
This was written for just such occasions: http://www.unifycommunity.com/wiki/index.php?title=ReplaceSelection
Answer by Waz · Sep 02, 2011 at 09:36 PM
Use EditorUtility.InstantiatePrefab. There are other useful prefab function in EditorUtility too.
Your answer
![](https://koobas.hobune.stream/wayback/20220612200706im_/https://answers.unity.com/themes/thub/images/avi.jpg)