Question by
helisa600 · May 28, 2020 at 05:44 PM ·
gameobjectprefab
Get prefab name from cloned object
Hello, I've object in my scene which is cloned prefab by Instantiate. I need name of cloned prefab, I'm try to use EditorUtility.GetPrefabParent but this is obsolete and I don't know how and what to use it in my situation. Can u tell me, what I should to use, to get name of this prefab??
Comment
Answer by Moritonal · Jul 31, 2020 at 12:49 PM
The answer is to use var prefabGameObject = PrefabUtility.GetCorrespondingObjectFromSource(clonedGameObject)
which'll return an instance of the GameObject as it is in the Prefab where you can then call prefabGameObject.name
.