/// <summary>
        /// Display the menu for the element.
        /// </summary>
        /// <param name="tbe">The element that is part of the menu to be displayed.</param>
        public static void ShowMenu(this IToolbarMenuElement tbe)
        {
            if (tbe == null || !tbe.menu.MenuItems().Any())
            {
                return;
            }

            var ve = tbe as VisualElement;

            if (ve == null)
            {
                return;
            }

            var worldBound = ve.worldBound;

            if (worldBound.x <= 0f)
            {
                // If the toolbar menu element is going over its allowed left edge, the menu won't be drawn.
                // (IMGUI seems to to the same as toolbar menus appear less attached to the left edge when the
                // windows are stuck to the left side of the screen as well as our menus)
                worldBound.x = 1f;
            }
            tbe.menu.DoDisplayEditorMenu(worldBound);
        }
Exemplo n.º 2
0
        public static void ShowMenu(this IToolbarMenuElement tbe)
        {
            if (tbe == null || !tbe.menu.MenuItems().Any())
            {
                return;
            }

            var ve = tbe as VisualElement;

            if (ve == null)
            {
                return;
            }

            tbe.menu.DoDisplayEditorMenu(ve.worldBound);
        }
Exemplo n.º 3
0
        public static void ShowMenu(this IToolbarMenuElement tbe)
        {
            if (!tbe.menu.MenuItems().Any())
            {
                return;
            }

            var ve = tbe as VisualElement;

            if (ve == null)
            {
                return;
            }

            Vector2 pos = new Vector2(ve.layout.xMin, ve.layout.yMax);

            pos = ve.parent.LocalToWorld(pos);

            tbe.menu.DoDisplayEditorMenu(pos);
        }