Find which object a component is attached to

It’s probably a dumb question, but I’ve been tearing hairs to find a GUI related script on some random object by mistake. Now every time I run my game there’s a box all over the screen (from the script).

How can I find which objects have a specific component in them?

Thanks,
Puppeteer

I am having trouble understanding what you are asking. Are you saying that there is a GUI box showing up and you don’t know how it got there?

Yeah, it’s a script with a OnGUI box. I dropped it by mistake on a random object in my game, and now I can’t find which object that is without going through all of them one by one.

Is there a way to just check where a certain component is? for example I click on a component and then it shows me all the objects in the game that this component is inside.

Dumb question, told you already :smile:

You could

Debug.Log(gameObject.name + ", child of " + transform.parent.name )

Inside the offending script. That would print you the object’s name and its parent’s name. That would at least narrow the search. :slight_smile:

That’s great Vicenti, I’ll be using it a lot, clumsy as I am.

btw, I found the script in the head of a cow… :smile:

No prob, I’ve had to do that myself a couple times already. xD