How to know if an object in hierarchy is a prefab

I’ve posted a question early today and I can’t delete it. I’ve figured out a much easier way to so this. The only thing I need to know is this:

I want to use foreach(transform child in transform) of the battlefield (in a card game) and I want to know if a child is from specific prefab or not. How can I know this? I may add some script to prefab (only for this testing) with some variable in it and check for each child in battlefild if he has this component and/or if he has that variable? Can you help me with writting this?

Thanks for help guys :slight_smile:

This sounds like something you should use tags for.

1 Like

Prefabs don’t exist at runtime. So you can’t do it this way.

Typically I would add an identifier component on to the GameObjects, and check for that. For simple systems you can just check the tag as @Thomas-Mountainborn suggested. Or even the name.