Объявление
public static void DisplayPopupMenu(Rect position, string menuItemPath, MenuCommand command);Описание
Отображает всплывающее меню.
Меню отображается в позиции pos
и создается из подменю, заданного menuItemPath
с помощью MenuCommand в качестве контекста меню.
using UnityEditor;
using UnityEngine;
using System.Collections;
// Показывает меню «Активы», когда вы щелкаете правой кнопкой мыши по прямоугольнику contextRect.
public class EditorUtilityDisplayPopupMenu : MonoBehaviour
{
void OnGUI()
{
Event evt = Event.current;
Rect contextRect = new Rect(10, 10, 100, 100);
if (evt.type == EventType.ContextClick)
{
Vector2 mousePos = evt.mousePosition;
if (contextRect.Contains(mousePos))
{
EditorUtility.DisplayPopupMenu(new Rect(mousePos.x, mousePos.y, 0, 0), "Assets/", null);
evt.Use();
}
}
}
}