Editor scripting: iterating project view assets

Hello,

how can I iterate through all (i.e. material) assets inside the current project (regardless if they are part of the current scene or not)?

And a second question, how can I know what assets are selected in the project view?

thx in advance

You can use System.IO.Directory.GetFiles to get a list of all files in the Assets folder.
http://msdn.microsoft.com/en-us/library/system.io.directory.getfiles.aspx

You can then use AssetDatabase.LoadMainAssetAtPath(“projectRelativePath”) to get the reference to the material. For performance reasons you probably want to check the extension against “.mat” prior to calling AssetDatabase.LoadMainAssetAtPath.
http://unity3d.com/support/documentation/ScriptReference/AssetDatabase.LoadMainAssetAtPath.html

ok, thx.