Custom Context menu for Project view?

I was wondering if it’s possible to add new context menu entries when right clicking in the Project view?
There are many, many short little scripts I would like to add here… 1 example is right clicking on a texture and have an ‘Auto-Material’ entry that quickly sets it up for you. Many other things in mind to.

I found lots of examples about context menu’s for GameObjects and inside your own custom editor windows, but what about the Project view?

Cheers!

I had the exact same idea with the Material thing, has anyone got any suggestions? I’ve been looking through editor classes and couldn’t find anything referring to the right-click context menu.

Tag your method with the MenuItem attribute, and add ‘Assets’ to the start of the path.

 [MenuItem("Assets/Stuff/DoSomething")]
        public static void Init()
        {
            var file = Selection.activeObject.name;
            DoSomethingToFile( file );
        }
5 Likes

Cool. Any idea how to “grey out” those items if for instance the wrong type of asset is selected?

Check this, you’ll find the answer.

Of better yet, the ContextMenu attribute. :wink:

http://docs.unity3d.com/Documentation/ScriptReference/ContextMenu.html

1 Like