[0b4] Editor: PrefabUtility.InstantiatePrefab from a scene prefab how to? Or broken?

Hi,

I’d like to clone a prefab that is already in the scene as a prefab.

var go = PrefabUtility.InstantiatePrefab(scene_prefab) as GameObject;

That produce a null gameobject. I tried gethandleof… and others, but that does not work anyway.
I’m doing anything wrong? Never had this issue.

Thank you…

1 Like

This may help

Edit: Necro-posting as this was unanswered and while searching in Google this was one of the first results. Better to have answers than having to keep looking for them.

Edit: Oh, a necro-post.

I think you’re looking for PrefabUtility.GetPrefabObject().

GameObject prefabAsset = PrefabUtility.GetPrefabObject(scene_object_which_may_be_part_of_prefab_instance);

GameObject instance;
if (prefabAsset != null)
    instance = PrefabUtility.InstantiatePrefab(prefabAsset);
else
    instance = Instantiate(scene_object_which_may_be_part_of_prefab_instance);