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
1
Question by undead-steve · Nov 08, 2013 at 08:37 PM · assetstagsassetdatabaselabels

How can I find all the asset labels in my project?

Is there a way to find out all of the asset labels attached to objects in my project? The unity UI knows, but I don't know where that's stored and it does not seem to be documented.

Bonus points: is there a way to set the contents of the search filter bar from script?

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 ThePunisher · Nov 08, 2013 at 09:12 PM 0
Share

I'm not entirely sure what you're asking, can you be a little more specific? Give us an example.

avatar image undead-steve · Nov 08, 2013 at 10:38 PM 0
Share

Unity somewhere has a global list of all the labels attached to assets in the assetdatabase - the list you see if you click the tag icon in the project filter bar, for example. I want to find that list.

avatar image ThePunisher · Nov 09, 2013 at 01:45 AM 0
Share

I gotcha. I wasn't aware there was such a thing, apologies. I see ArkaneX already answered, glad you found what you needed.

1 Reply

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

Answer by ArkaneX · Nov 08, 2013 at 11:00 PM

You can get all labels calling internal AssetDatabase.GetAllLabels method via reflection. The internal code might of course change in a future Unity version, but I think it's highly unlikely. I bet you can fill a search filter using reflection too, but this might be a bit harder.

Code for retrieving all the labels:

 var flags = System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod;
 var dicLabels = (System.Collections.Generic.Dictionary<string, float>)typeof(AssetDatabase).InvokeMember("GetAllLabels", flags, null, null, null);
 foreach (var label in dicLabels.Keys)
 {
     Debug.Log(label);
 }

EDIT: as a side note - this is an editor only script.

Comment
Add comment · Show 3 · 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 undead-steve · Nov 09, 2013 at 01:01 AM 0
Share

Works like a charm, thanks!

Is it possible to remove the built-in ones that aren't relevant?

avatar image ArkaneX · Nov 09, 2013 at 12:54 PM 1
Share

In case you only want to retrieve labels used in your project, I can suggest using documented AssetDatabase methods. Sample code:

 var paths = AssetDatabase.GetAllAssetPaths();
 foreach (var path in paths)
 {
     var asset = AssetDatabase.Load$$anonymous$$ainAssetAtPath(path);
     var labels = AssetDatabase.GetLabels(asset);
     if (labels.Length > 0)
     {
         Debug.Log(asset.name + ": " + string.Join(",", labels));
     }
 }

Please note that in case of composite assets, Load$$anonymous$$ainAssetAtPath will probably not be enough, and you should be using other LoadXXX methods.

avatar image AleMarcati · Mar 26 at 02:37 PM 0
Share

Is there a way to search the scene for all objects that are assets with a certain label? I'm trying to search l:Dynamic for objects that have the Dynamic tag but it only finds in the project, not in the scene.

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

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

Related Questions

Where are asset labels stored? 1 Answer

AssetDatabase: Replacing an asset, but leaving reference intact 2 Answers

Scriptable Object not saving changes to a list. 0 Answers

Addressables - Use Asset Database (faster) - Not loading assets within a folder 1 Answer

Best tools for asset making? 0 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