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 ?

2 Answers

2

This was written for just such occasions: unifycommunity.com

broken link! :*(

Use EditorUtility.InstantiatePrefab. There are other useful prefab function in EditorUtility too.