Reconnect programmatically instantiated prefab (419853)

Hi guys,

first of all: this is my first post in these forums, so be patient :wink:

I have been using unity for a while now. Besides the great scripting support during runtime I discovered the great features of editor scripting, lately.

Now I have one very urgent question. When doing this:

Object prefab = AssetDatabase.LoadAssetAtPath(newPrefabPath, typeof(GameObject));
GameObject clone = GameObject.Instantiate(prefab) as GameObject;

I can’t do:

EditorUtility.ReconnectToLastPrefab(clone);

And I can’t do:

EditorUtility.GetPrefabParent(clone);

Problem is, I have lots of scene objects (gameobjects) that are not prefabbed. I can create prefabs and I can instantiate (off thess prefabs) new gameobjects in place. But then these are not connected to their prefab.

How can I Instantiate a Prefab and Reconnect the resulting Object to this Prefab?

Since there seems to be no answer, I posted it to unity answers:

http://answers.unity3d.com/questions/17376/reconnect-programmatically-instantiated-prefab

Is EditorUtility.InstantiatePrefab what you are looking for?

exactly this was the answer :wink: