Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Game Development How to Make a Video Game Score, Enemies, and Game State Create Enemy Navigation and AI

J R
J R
2,037 Points

How do I know or get the gameObject that a script component belongs to?

Just exploring others work and I open the scripts folders but I don't know how to find the gameObject where this script was created as a component.

2 Answers

Alan Mattanó
PLUS
Alan Mattanó
Courses Plus Student 12,188 Points

Select the project script, right click --> "Find Reference in Scene"

The script can be use in any game object. First open your game selecting ( left click) two times the scene in the project window. After your game is open, If in your game a script is attach to a game object as a component, you can select the script in the Project window. Then after selecting it press right click with the mouse button and a pop up window will appear with options. Select "Find Reference in Scene". This will make a filter in the Hierarchy windows showing you only the Game objects that has this script attach to it.

To clean the filter search just click the "X" on top of the Hierarchy windows.

J R
J R
2,037 Points

Excellent! It was so simple, just right click :) Thanks !

Alan Mattanó
Alan Mattanó
Courses Plus Student 12,188 Points

Remember to use comment to add a comment here and choose answer to answer the question. Choose the best answer so that other do not look into problems that they have been resolved. Nice I can help.