Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by ina · Dec 30, 2010 at 05:26 AM · gameobjecthierarchyattachide

Quickly isolate GameObjects in Hierarchy with scripts in them?

In the Unity IDE: Is there a way to quickly find out which GameObjects in Hierarchy have scripts attached? Is there a way to find out which scripts are attached to which objects?

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Justin Warner · Dec 30, 2010 at 05:28 AM 0
Share

Get all the objects in the scene in an array, and do a GetComponent with an each statement, and then /win... Sorry, I don't know... But this is plausible, but very bad =P.

avatar image ina · Dec 30, 2010 at 05:58 AM 0
Share

i guess that could be a handy editor script, outputting to Debug.Log... but i was hoping for more integration with the IDE, so i could easily click to inspect each one with scripts in them

2 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by chief1234 · Aug 23, 2011 at 08:14 PM

Not sure when this feature was added, but now there is a built-in solution.

Simply type the FULL NAME of the component you're looking for into the hierarchy search box and it will highlight all objects with that component.

Example: typing "anim" will only come up with gameObjects with "anim" in the name.

typing "animation" will come up with all gameObjects with "animation" components attached.

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image deram_scholzara · Sep 12, 2013 at 02:01 AM 0
Share

For some reason, "animation" doesn't work anymore (I'm guessing it hasn't worked since they added $$anonymous$$ecanim).

avatar image TheCheese · Sep 12, 2013 at 12:53 PM 0
Share

One small correction - this is also case-sensitive now as well (it wasn't always). And yes, you're right - animation, or Animation, does not seem to work anymore.

avatar image
3

Answer by yoyo · Dec 30, 2010 at 06:15 PM

Add this script to your Assets\Editor folder and you will get a menu item that dumps information about the scene to a text file, including which components (scripts) are attached to which objects.

It basically implements Justin's suggestion.

You could modify the script to be more fully integrated with the IDE. Reverse lookup would be a cool feature -- i.e. "select all game objects using this script." Hmm, useful enough that maybe I'll go implement it ...

OK, so I got a little carried away, but see http://zeroandone.ca/unity for a package that implements this and other features. Here's a screenshot (click here for full size image) ...

alt text

You can grab the package and look at the source code, or just use it. The implementation does roughly this ...

  • select your script in the Project view (identified as Selection.objects from an editor script)
  • get this as a MonoScript object representing the script asset
  • use MonoScript.GetClass to determine the component type (returns null for scripts that don't implement MonoBehaviour)
  • search all the root objects of the scene (transform.parent == null) and their descendants for use of the component type, with GameObject.GetComponentsInChildren
  • select the found objects by setting Selection.objects
  • Debug.Log as well, with a game object context parameter for handy highlighting
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ina · Dec 30, 2010 at 07:00 PM 0
Share

do post your results!

avatar image yoyo · Dec 31, 2010 at 06:59 AM 0
Share

stay tuned, should have something tomorrow ... (famous last words)

avatar image yoyo · Jan 11, 2011 at 04:28 AM 0
Share

See edited answer -- follow the zeroandone link to see what I came up with. Heck, I'll edit my answer again and add a screenshot ...

avatar image Turbo · Feb 18, 2011 at 03:13 PM 0
Share

brilliant, thanks so much. This should be standard in Unity its used so much.

avatar image yoyo · Feb 18, 2011 at 03:35 PM 0
Share

Cool, thanks, I hope it's useful. I need to go back to that script and make it better at digging into arrays and lists, which I now know how to do.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Unity IDE: Finding out object type of arbitrary item in Hierarchy 3 Answers

C# Scripts don't attach to game objects, what happened? 2 Answers

True scale of a visible GameObject with many childs 1 Answer

How to add an asset to a script-enabled public game object? 1 Answer

Deleting GameObjects 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges