- Home /
Search assets by labels ?
Hello there,
I'm currently making a custom tool for my company, and I need to search some assets in the inspector by their label.
I wrote a simple script that labels my assets (indeed, meshs) at the import, like this : if the name is like "Asset$info", I create a label named "info".
What I would like, is to retrieve those assets in an editor script. Currently, I use something like this :
Code:
var testAssets : Object[] = Resources.FindObjectsOfTypeAll(MeshFilter);
for (obj in testAssets)
{
var labels : String[] = AssetDatabase.GetLabels(obj);
if (labels.length>0)
{
if (labels[0] == "TestLabel")
{
FoSomething();
}
}
}
And, fore some reason I don't understand, this wont work every time. If I just selected some assets in the project with matching labels before running the script, it works, else not, like if the objects were in cache or something like this.
Does anyone have already had a issue like this, or have a method to achieve what I want (even with an alternative to the labels system).
Thanks.
Answer by robertmathew · Apr 04, 2011 at 03:21 PM
I'm not using asset bundles, This piece of code is running in an editor window.
Your answer
Follow this Question
Related Questions
Unity Asset Labels Searching 0 Answers
Where are asset labels stored? 1 Answer
How can I find all the asset labels in my project? 1 Answer
Cannot find 3D Prefab after doing a build. 0 Answers
Selling with standard assets. 2 Answers