Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Пример использования - проверяет ПКМ па последнему отрисованному элементу
- CheckContextMenu(ShowMenu);
- // Метод вызова меню
- private bool CheckContextMenu(Action menuMethod)
- {
- var w = EditorWindow.mouseOverWindow;
- if (w == null) return false;
- Event current = Event.current;
- if (current.isMouse && current.button == 1)
- if (GUILayoutUtility.GetLastRect().Contains(current.mousePosition))
- {
- menuMethod.Invoke();
- return true;
- }
- return false;
- }
- // Пример меню
- void ShowMenu()
- {
- GenericMenu menu = new GenericMenu();
- menu.AddDisabledItem(new GUIContent("Actor action menu"));
- menu.AddItem(new GUIContent("Add"), false, AddActorAction);
- menu.AddItem(new GUIContent("Clone"), false, CloneActorAction);
- menu.AddItem(new GUIContent("Delete"), false, DeleteActorAction);
- menu.ShowAsContext();
- }
- // Пункты меню
- void AddActorAction()
- {}
- void CloneActorAction()
- {}
- void DeleteActorAction()
- {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement