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
9
Question by Stucko_Stuck · Dec 16, 2010 at 03:07 PM · editor

How to know where a particular script is being used?

Hi I created a project a while back. Now I'm opening it and I find that I've forgotten most of what I've done. I'm trying to remove a script from the game but don't remember which object/prefab I attached it to. Is there a way to see where a particular script is being used at? something like "select dependencies" but the opposite.

Comment
Add comment · Show 1
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 fallingmoon · Apr 02, 2016 at 12:59 AM 0
Share

This tool can solve your problem. Check it out.

3 Replies

· Add your reply
  • Sort: 
avatar image
13
Best Answer

Answer by jonas-echterhoff · Dec 16, 2010 at 03:28 PM

If you know which scene it is in, just use the search field in the Hierarchy view (in Unity 3). Be sure to type the full script name, or you won't see any results.

Comment
Add comment · Show 4 · 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 Stucko_Stuck · Dec 16, 2010 at 03:37 PM 0
Share

Aah no wonder I cant find it, I didnt prefab the object. Thanks :)

avatar image siddharth3322 · Sep 07, 2014 at 04:13 PM 0
Share

Thanks for this help.

avatar image illustir · Aug 20, 2015 at 09:58 AM 0
Share

But if you want to know whether it is being used anywhere in your project?

avatar image JoSaindon · Jul 05, 2019 at 11:41 AM 0
Share

It won't find if it is on a prefab that is instanciated at runtime in your scene tough.

avatar image
17

Answer by ynedelin · Sep 05, 2014 at 04:52 AM

In the project view right click on the script and choose "Find References In Scene".

Comment
Add comment · Show 1 · 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 MelvinG24 · Feb 27 at 02:07 AM 0
Share

you should be the best answer

avatar image
1

Answer by ThePilgrim · Jul 21, 2016 at 09:25 PM

 public class FindPrefabsWithComponent : MonoBehaviour {
 
     public GameObject[] prefabs;
 
 
     void Start()
     {
         FindPrefabsWithComponentType<Rigidbody>();
     }
 
 
     private void FindPrefabsWithComponentType<T>() where T : Component
     {
         print("Searching for components...");
         foreach (var prefab in prefabs)
         {
             T foundComponent = prefab.GetComponentInChildren<T>();
             if (foundComponent != null)
             {
                 print("Found component in " + foundComponent.name);
             }
         }
         print("search complete");
     }
 }

If you want to find all prefabs that the script is attached to, even ones that are not in any of your scenes, you can follow these instructions:

  1. Create the FindPrefabsWithComponent c# script above, but replace "Rigidbody" with whatever script you are wanting to find.

  2. Create a new game object in your scene and attach the FindPrefabsWithComponent script.

  3. Click the small lock icon in the top right of the inspector window to lock the inspector view onto your new game object.

  4. In your project, search for all prefabs with "t:Prefab" or by using the filter button immediately to the right of the search box in the project window.

  5. Select all of the prefabs in the project window (Ctrl-A on windows) and drag them onto "Prefabs" in the FindPrefabsWithComponent component in the inspector window.

  6. Run the game. It will print out the name of the game object that the script is attached to.

Comment
Add comment · 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

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Detecting serialization reload in editor 1 Answer

UniSciTE in version 3.x Script Edtior 1 Answer

problem with the digits of my timer 1 Answer

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Show prefab/GO in viewport via script 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