Exemplo n.º 1
0
        protected override void KeyEvent()
        {
            Event ev = Event.current;

            switch (ev.type)
            {
            case EventType.KeyDown:
            {
                switch (ev.keyCode)
                {
                case KeyCode.Return:
                case KeyCode.KeypadEnter:
                {
                    if (GUIExpansion.HasKeyControl(ev.keyCode) == false)
                    {
                        string path = SelectSelectedElements(x => x.path)?.First();
                        if (string.IsNullOrEmpty(path) == false)
                        {
                            AssetDatabase.OpenAsset(AssetDatabase.LoadMainAssetAtPath(path));
                            GUIUtility.ExitGUI();
                        }
                        GUIExpansion.GrabKeyControl(ev.keyCode, treeViewControlID);
                    }
                    break;
                }
                }
                break;
            }

            case EventType.KeyUp:
            case EventType.Ignore:
            {
                GUIExpansion.ReleaseKeyControl(ev.keyCode);
                break;
            }
            }
        }
Exemplo n.º 2
0
        public void OnGUI(Contents contents)
        {
            Event ev = Event.current;

            if (ev.type == EventType.KeyDown)
            {
                switch (ev.keyCode)
                {
                case KeyCode.F:
                {
                    FilterPath();
                    ev.Use();
                    break;
                }

                case KeyCode.L:
                {
                    if (ev.control != false)
                    {
                        searchField.SetFocus();
                        ev.Use();
                    }
                    break;
                }
                }
            }
            using (new EditorGUILayout.VerticalScope())
            {
                using (new EditorGUILayout.HorizontalScope(EditorStyles.toolbar))
                {
                    /* リスト表示廃止に伴い無効化 */
                        #if false
                    int mouseButton;

                    mouseButton = GUIExpansion.Toggle(viewType == View.Type.kTree,
                                                      new GUIContent(EditorGUIUtility.Load(treeTexture) as Texture2D),
                                                      EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));
                    switch (mouseButton)
                    {
                    case 0:
                    {
                        if (viewType != View.Type.kTree)
                        {
                            viewType = View.Type.kTree;
                            Apply();
                        }
                        break;
                    }

                    case 1:
                    {
                        if (viewType == View.Type.kTree)
                        {
                            var contextMenu = new GenericMenu();

                            contextMenu.AddItem(new GUIContent("ExpandAll"), false, () =>
                                {
                                    view.ExpandAll();
                                });
                            contextMenu.AddItem(new GUIContent("CollapseAll"), false, () =>
                                {
                                    view.CollapseAll();
                                });
                            contextMenu.ShowAsContext();
                        }
                        break;
                    }
                    }
                    mouseButton = GUIExpansion.Toggle(viewType == View.Type.kList,
                                                      new GUIContent(AssetDatabase.LoadMainAssetAtPath(listTexture) as Texture2D),
                                                      EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));
                    switch (mouseButton)
                    {
                    case 0:
                    {
                        if (viewType != View.Type.kList)
                        {
                            viewType = View.Type.kList;
                            Apply();
                        }
                        break;
                    }

                    case 1:
                    {
                        if (viewType == View.Type.kList)
                        {
                        }
                        break;
                    }
                    }
                    GUILayout.Space(6);
                        #endif
                        #if false
                    if (viewType == View.Type.kList)
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        EditorGUILayout.TextField("Asssets/", EditorStyles.toolbarTextField);
                        EditorGUI.EndDisabledGroup();
                    }
                        #endif
                        #if WITH_SEARCHSTRING
                    string newSearchString = searchField.OnToolbarGUI(searchString, GUILayout.ExpandWidth(true));
                    if (searchString != newSearchString)
                    {
                        searchString = newSearchString;
                        searchFilter.Change(searchString);
                        view.Reload();
                    }
                        #else
                    view.searchString = searchField.OnToolbarGUI(view.searchString, GUILayout.ExpandWidth(true));
                        #endif
                    GUILayout.Space(4);

                    var  content = EditorGUIUtility.TrIconContent(typeTexture, "Search by Type");
                    Rect rect    = GUILayoutUtility.GetRect(content, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false));

                    if (EditorGUI.DropdownButton(rect, content,
                                                 FocusType.Passive, EditorStyles.toolbarButton) != false)
                    {
                        PopupWindow.Show(rect, new PopupList(objectTypes));
                    }
                }
                using (var scope = new EditorGUILayout.VerticalScope(GUILayout.ExpandHeight(true)))
                {
                    OnContextMenuEvent(contents, Event.current);
                    view.OnGUI(scope.rect);
                }
            }
        }