Accessing the project panel's selection from an editor script?

Hi fellow uniters!

I’m currently having to change the compression and kbps of lots of wav assets in my project panel and I would looooove a way to make an editor script that sets those parameters for all my selected assets, like I do in scripts applying to the hierarchy panel’s selection. Right now, I need to change audio parameters but this would apply to many tedious tasks with assets inherent to game development.

Is that possible? I can’t seem to find how, I see AssetImporter/AudioImporter that contains the parameters I need to modify, but no way to loop through my asset selection.

Thanks for any help.

EDIT: This doesn’t work, see comments

Thanks to testure’s comment, I found some more tricks (obvious ones) using Selection and a couple other editor classes so here’s the final solution with a sample code. After further playing around, I found it kinda weird how it works, I don’t see the parameters change in the inspector but after running the script, I select something else, and it asks if I want to apply the new parameters on the asset, I have to click “revert” and NOT “apply”, then I do see the new parameters in the inspector, it’s kinda weird and backward but it works.

[MenuItem("Tools/DogTek/SetSoundParams")]
static void SetSoundParams()
{
    for (int i = 0; i < Selection.objects.Length; ++i)
    {
        Object obj = Selection.objects*;*

string szPath = AssetDatabase.GetAssetPath(obj);
AudioImporter audioImporter = AssetImporter.GetAtPath(szPath) as AudioImporter;
audioImporter.format = AudioImporterFormat.Compressed;
audioImporter.loopable = true;
audioImporter.compressionBitrate = 96000;
}
}

If you inherit from EditorWindow rather than Editor, you have access to the OnSelectionChange event. Once there, you can cache the selected gameobject with Selection.activeGameObject, and do whatever you want with it.

further reading:
http://unity3d.com/support/documentation/ScriptReference/EditorWindow.OnSelectionChange.html