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.