Beispiel #1
0
        public static void OpenContextMenu(IEnumerable<ContextMenuItem> items)
        {
            GenericMenu contextMenu = new GenericMenu();

            foreach (var item in items)
            {
                var handler = item.Handler;
                contextMenu.AddOptionalItem(
                    item.IsEnabled, new GUIContent(item.Caption), item.IsChecked, () => handler());
            }

            contextMenu.ShowAsContext();
        }
Beispiel #2
0
        public static void OpenContextMenu(Vector2 startPos, IEnumerable<ContextMenuItem> items)
        {
            GenericMenu contextMenu = new GenericMenu();

            foreach (var item in items)
            {
                var handler = item.Handler;
                contextMenu.AddOptionalItem(
                    item.IsEnabled, new GUIContent(item.Caption), item.IsChecked, () => handler());
            }

            contextMenu.DropDown(new Rect(startPos.x, startPos.y, 0, 0));
        }