示例#1
0
 ///Shows the Generic Menu as a browser with CompleteContextMenu.
 public static void ShowAsBrowser(this GenericMenu menu, string title, System.Type keyType = null)
 {
     if (menu != null)
     {
         GenericMenuBrowser.Show(menu, Event.current.mousePosition, title, keyType);
     }
 }
示例#2
0
        ///Shows the popup menu at position and with title
        public static GenericMenuBrowser Show(GenericMenu newMenu, Vector2 pos, string title, System.Type keyType)
        {
            var browser = new GenericMenuBrowser(newMenu, title, keyType);

            PopupWindow.Show(new Rect(pos.x, pos.y, 0, 0), browser);
            return(browser);
        }
示例#3
0
 ///Shows the Generic Menu as a browser with CompleteContextMenu.
 public static void ShowAsBrowser(this GenericMenu menu, Vector2 pos, string title, System.Type keyType = null)
 {
     if (menu != null)
     {
         GenericMenuBrowser.Show(menu, pos, title, keyType);
     }
 }
示例#4
0
        ///Shows the popup menu at position and with title immediately
        public static void ShowAsync(Vector2 pos, string title, System.Type keyType, System.Func <GenericMenu> getMenu)
        {
            var browser = new GenericMenuBrowser(null, title, keyType);
            var task    = Task.Run(() => getMenu()).ContinueWith((m) => browser.SetMenu(m.Result));

            PopupWindow.Show(new Rect(pos.x, pos.y, 0, 0), browser);
        }
 //Generate the tree node structure out of the items
 static void GenerateTree()
 {
     loadProgress = 0;
     items        = EditorUtils.GetMenuItems(boundMenu);
     leafNodes    = new List <Node>();
     for (var i = 0; i < items.Length; i++)
     {
         loadProgress = i / (float)items.Length;
         var  item     = items[i];
         var  itemPath = item.content.text;
         var  parts    = itemPath.Split('/');
         Node current  = rootNode;
         var  path     = string.Empty;
         for (var j = 0; j < parts.Length; j++)
         {
             var part = parts[j];
             path += "/" + part;
             Node child = null;
             if (!current.children.TryGetValue(part, out child))
             {
                 child = new Node {
                     name = part, parent = current
                 };
                 child.fullPath         = path;
                 current.children[part] = child;
                 if (part == parts.Last())
                 {
                     child.item = item;
                     leafNodes.Add(child);
                 }
             }
             current = child;
         }
     }
 }
            //Set favorite state
            void SetFavorite(bool fav)
            {
                if (fav == true && !isFavorite)
                {
                    GenericMenuBrowser.AddFavorite(fullPath);
                }

                if (fav == false && isFavorite)
                {
                    GenericMenuBrowser.RemoveFavorite(fullPath);
                }
            }
 //init
 public GenericMenuBrowser(GenericMenu newMenu, string title, System.Type keyType)
 {
     current               = this;
     this.title            = title;
     currentKeyType        = keyType;
     rootNode              = new Node();
     currentNode           = rootNode;
     headerStyle           = new GUIStyle("label");
     headerStyle.alignment = TextAnchor.UpperCenter;
     hoveringIndex         = -1;
     search     = null;
     lastSearch = null;
     SetMenu(newMenu);
 }
 public override void OnClose()
 {
     SavePrefs();
     EditorWindow.FocusWindowIfItsOpen(wasFocusedWindow != null ? wasFocusedWindow.GetType() : null);
     current = null;
 }