Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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
11
Question by amirabiri · Oct 23, 2011 at 11:13 AM · editorassets

Is there a way find usage of an asset?

Is there a way to find all the occurrences of a given asset (where it is being used). i.e the opposite of "select dependencies".

It's easy to click on an asset or prefab and then navigate to its dependencies (for example find the texture used by a given material). I'm looking for the reverse navigate - from the texture find all the materials that use it, if any.

Is there a way to achieve this?

Comment
Add comment · Show 3
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 Bonfire-Boy · Sep 07, 2016 at 11:54 PM 2
Share

One approach you can use is to do it outside of Unity.

Each asset's meta file contains a guid which is used to refer to that asset in other files. So if you find that guid and search other files for it, you can find the references, whether they're in scenes or prefabs or whatever.

There can be a bit of head-scratching to do to work out how the asset is being used, but often you can work it out from the context in file, and anyway it gives you a comprehensive starting point (you can always then switch to Unity). I find it handy when I'm deleting an asset and want to be sure that it's not being used before doing so.

avatar image fafase Bonfire-Boy · Nov 19, 2016 at 07:05 AM 0
Share

I'll support that approach, you could create an editor script where you give the items you are looking for and the scenes in which they should be found.

Your scene file is just a YA$$anonymous$$L, so it can be treated like a text file. You can then search whether the GUID of the given assets are present in the scene, If so, you can find what is the object/script that refers to it.

The result can be printed in the Editor window. Easier said than done but this is actually just basic string manipulation. Best is to start with looking at the scene YA$$anonymous$$L file and try to understand the logic behind it.

avatar image Gotama Bonfire-Boy · Feb 28, 2017 at 10:31 AM 0
Share

This tip helped me. Think is useful in bug and complex and messy unity projects.

6 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by Gotlight · Sep 07, 2016 at 09:44 PM

Is there a way to find all the occurrences of a given asset (where it is being used). i.e the opposite of "select dependencies".

Hi! There's a tool which has the opposite core idea to Unity's Select Dependencies. After several major updates, an asset offers great interface for working with results and is much faster.

For example, it offers:

  • Search for usages of: Scenes, Scripts, Shaders, Materials, Sprites, Prefabs, Textures, Sounds

  • Search for usages in: Prefabs, Scenes, Atlases, Materials

  • Search inside Project and inside Scene as well

Asset Store link:

  • https://www.assetstore.unity3d.com/en/#!/content/59997

alt text

Denis


usages23.png (100.4 kB)
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
avatar image
5

Answer by BorisOkunskiy · Mar 09, 2020 at 08:30 AM

I know it's been a while, but you can open .meta file of your asset in question, grab the value of guid field and then simply search by this value through all the files (e.g. by using git grep <my_asset_guid>).

This gives you a really quick and useful outlook of whether the asset is used and where exactly. Of course it might not fit every bill, but this is my favorite way of "finding usages" because it's virtually agnostic to Unity version and doesn't depend on any extra downloads or scripting.

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 dan_ginovker · Apr 21, 2021 at 03:46 PM 0
Share

This is brilliant! Thank you!!

avatar image
1

Answer by Catlard · Oct 23, 2011 at 11:36 AM

Here:

     var go : GameObject;
     var gos = GameObject.FindGameObjectsWithTag ("TAG YOU THINK YOU WANT");
     //finds all gameobjects of that tag, loads them into an array
     for (go in gos)
     {
          if(go.renderer.material == " MATERIAL NAME HERE")
          {
              print(gameObject);
          }
 }
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 Catlard · Oct 23, 2011 at 11:36 AM 0
Share

hopefully you've got a good idea of which tags you're looking for.

avatar image amirabiri · Oct 23, 2011 at 09:08 PM 0
Share

O$$anonymous$$ so your answer told me that there is no simple built-in way to do this in Unity and that I have to resort to code. However it has to be an Editor script and is more complicated than simply finding objects by tags. So I created a little editor script to achieve this.

Thanks for your answer, it definitely put me on the right track.

avatar image
1

Answer by Sarchophagi · Nov 02, 2019 at 05:14 AM

Use the following FREE asset. Instructions are on the link. Really great.
https://github.com/yasirkula/UnityAssetUsageDetector

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
avatar image
0

Answer by Catlard · Oct 23, 2011 at 11:15 AM

When I want to find this out, usually I take the asset out of the project, or make it cause an error in some way--and then all the objects with that asset will throw errors. This works for scripts, which is usually what I'm looking for when I'm doing this. Does that answer your question?

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 amirabiri · Oct 23, 2011 at 11:29 AM 0
Share

I'm trying to do this with other assets like textures and materials. If I delete a used texture or material (or any other non-script asset) I don't get errors. Ins$$anonymous$$d things just appear incorrectly, sometimes in subtle ways.

avatar image Bonfire-Boy amirabiri · Sep 07, 2016 at 11:58 PM 0
Share

See my comment to the question above - it describes a way of reassuring yourself that an asset is not being used.

avatar image Catlard · Oct 23, 2011 at 11:33 AM 0
Share

Yes, this is a trickier business. I suppose the easiest way to do it then would be just to identify them by code, a la a function that goes through every game object. Here's some code that might do it for you, in the next answer.

avatar image Tortuap · Jun 03, 2015 at 03:57 PM 0
Share

Removing a script won't make the editor reporting it as an error. You'll get a warning for a missing script and empty components in your game objects, without the missing script name. Not that useful.

  • 1
  • 2
  • ›

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

12 People are following this question.

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

Related Questions

Custom Editor: show asset folders in ObjectField 2 Answers

Change angle of camera in prefab preview 4 Answers

Access or remove background color of AssetPreview 2 Answers

How to Load/Unload assets in Editor? 0 Answers

How would one make Unity Check for new assets? 2 Answers


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