- Home /
Question by
Nirvan · Jan 06 at 06:06 AM ·
menuitemcontextmenu
How to add right click context menu to /assets, which display it only for one file type
I want to add context menu when hitting right mouse button on the material file in project browser, but I don't want to display it when hitting right mouse button in other file type than Material.
So, I want to call something like this:
[MenuItem("Assets/Open in Material Edit")]
private static void OpenMaterialEdit(MenuCommand menuCommand)
{
for (int i = 0; i < Selection.objects.Length; i++)
{
if (Selection.objects[i] is Material)
{
if (Get == null) Init();
Get.TargetMaterial = Selection.objects[i] as Material;
return;
}
}
}
But now it will be displayed on every file in project, when I want to have this option visible only for Material type.
There is something like: [MenuItem("CONTEXT/Material/Open in Material Edit")] But it's for hitting right mouse button on the added component inside inspector window, maybe there is something similar for assets file menu item?
Comment