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?

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)

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