- Home /
Check if GameObjects are from the same prefab?
For my pooling system, I'd like to check if 2 game objects are of the same prefab in C#. If two objects are both instantiated from the prefab, I'd like to know. How can I do this?
Comment
Best Answer
Answer by Manny Calavera · Mar 07, 2015 at 01:24 AM
Take a look at this one: PrefabUtility.GetPrefabType()
http://docs.unity3d.com/ScriptReference/PrefabUtility.GetPrefabType.html
Please notice that this only works in the editor, not at runtime.
How does this help differentiate between a prefab of an enemy
and of a bullet
? Wouldn't the PrefabType of each of these prefabs just be Prefab
? I suppose I could just use the name property.